Skip to content

Commit 9e85522

Browse files
committed
Update workflow state and context to the workflow object
1 parent 297135d commit 9e85522

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

src/controller.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ class Controller {
4747
'feeder:status': [],
4848
'sender:status': [],
4949
'workflow:state': [],
50-
'controller:state': [],
51-
'controller:settings': []
50+
'controller:settings': [],
51+
'controller:state': []
5252
};
5353

5454
context = {
@@ -67,9 +67,12 @@ class Controller {
6767
loadedControllers = [];
6868
port = '';
6969
type = '';
70-
state = {};
7170
settings = {};
72-
workflowState = 'idle'; // running|paused|idle
71+
state = {};
72+
workflow = {
73+
state: 'idle', // running|paused|idle
74+
context: {}
75+
};
7376

7477
// @param {object} io The socket.io-client module.
7578
constructor(io) {
@@ -112,19 +115,20 @@ class Controller {
112115
this.type = '';
113116
this.state = {};
114117
this.settings = {};
115-
this.workflowState = 'idle';
118+
this.workflow.state = 'idle';
116119
}
117120
if (eventName === 'workflow:state') {
118-
this.workflowState = args[0];
119-
}
120-
if (eventName === 'controller:state') {
121-
this.type = args[0];
122-
this.state = { ...args[1] };
121+
this.workflow.state = args[0];
122+
this.workflow.context = { ...args[1] };
123123
}
124124
if (eventName === 'controller:settings') {
125125
this.type = args[0];
126126
this.settings = { ...args[1] };
127127
}
128+
if (eventName === 'controller:state') {
129+
this.type = args[0];
130+
this.state = { ...args[1] };
131+
}
128132

129133
const listeners = ensureArray(this.listeners[eventName]);
130134
listeners.forEach(listener => {

0 commit comments

Comments
 (0)