You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
765 B
45 lines
765 B
export default `export default class Context {
|
|
constructor(opts) {
|
|
this._init(opts);
|
|
}
|
|
|
|
_init(opts = {}) {
|
|
const { payload = {} } = opts;
|
|
this.curNode = null;
|
|
this.context = Object.create(null);
|
|
this.payload = Object.freeze({ ...payload });
|
|
}
|
|
|
|
_transitTo(node, lastRet) {
|
|
this.curNode = node;
|
|
this.lastRet = lastRet;
|
|
}
|
|
|
|
prepare(opts = {}) {
|
|
this.payload = opts.payload;
|
|
this.context = {};
|
|
}
|
|
|
|
getConfig() {
|
|
return this.curNode.data.configData;
|
|
}
|
|
|
|
getPayload() {
|
|
return this.payload;
|
|
}
|
|
|
|
getPipe() {
|
|
return this.lastRet;
|
|
}
|
|
|
|
getContext() {
|
|
return this.context;
|
|
}
|
|
|
|
setContext(data = {}) {
|
|
Object.keys(data).forEach((key) => {
|
|
this.context[key] = data[key];
|
|
});
|
|
}
|
|
}
|
|
`;
|
|
|