MCPcopy Create free account
hub / github.com/QuarkGluonPlasma/react-course-code / Context

Class Context

react-flow-test/src/logic/context.js:1–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1export default class Context {
2 constructor(opts) {
3 this._init(opts);
4 }
5
6 _init(opts = {}) {
7 const { payload = {} } = opts;
8 this.curNode = null;
9 this.context = {};
10 this.payload = Object.freeze({ ...payload });
11 }
12
13 _transitTo(node, lastRet) {
14 this.curNode = node;
15 this.lastRet = lastRet;
16 }
17
18 getConfig() {
19 return this.curNode.data.configData;
20 }
21
22 getPayload() {
23 return this.payload;
24 }
25
26 getPipe() {
27 return this.lastRet;
28 }
29
30 getContext() {
31 return this.context;
32 }
33
34 setContext(data = {}) {
35 Object.keys(data).forEach((key) => {
36 this.context[key] = data[key];
37 });
38 }
39}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected