@indra.ai/deva 1.56.3 → 1.56.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +8 -3
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -71,6 +71,7 @@ class Deva {
|
|
|
71
71
|
this._events = config.events; // set the core system events
|
|
72
72
|
this._bound = new Map(); // evt -> wrapper registered on the shared bus
|
|
73
73
|
this._pending = new Set(); // pending asks: {evt, handler, timer}
|
|
74
|
+
this._stateBound = []; // [event, handler] pairs for the state listeners
|
|
74
75
|
|
|
75
76
|
this._feature = config.feature; // set the feature from config data.
|
|
76
77
|
this._features = config.features; // set the features from config data.
|
|
@@ -174,12 +175,14 @@ class Deva {
|
|
|
174
175
|
_assignListeners() {
|
|
175
176
|
return new Promise((resolve, reject) => {
|
|
176
177
|
try {
|
|
178
|
+
|
|
177
179
|
// set the default listeners for the states of the agent.
|
|
178
180
|
for (let state in this._states) {
|
|
179
181
|
if (typeof this[state] === 'function') {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
182
|
+
const evt = `${this._agent.key}:${state}`;
|
|
183
|
+
const handler = packet => this[state](packet);
|
|
184
|
+
this._stateBound.push([evt, handler]); // keep it so shutdown can remove it
|
|
185
|
+
this.events.on(evt, handler);
|
|
183
186
|
}
|
|
184
187
|
}
|
|
185
188
|
|
|
@@ -211,6 +214,8 @@ class Deva {
|
|
|
211
214
|
if (handler) this.ignore(evt, handler); // ignore() already calls events.removeListener
|
|
212
215
|
}
|
|
213
216
|
this._bound.clear();
|
|
217
|
+
for (const [evt, handler] of this._stateBound) this.ignore(evt, handler); // state listeners from _assignListeners
|
|
218
|
+
this._stateBound = [];
|
|
214
219
|
return this._clearPending(); // pending asks go in the same pass
|
|
215
220
|
}
|
|
216
221
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "23221940810208468106",
|
|
3
3
|
"name": "@indra.ai/deva",
|
|
4
|
-
"version": "1.56.
|
|
4
|
+
"version": "1.56.4",
|
|
5
5
|
"description": "Deva Core a Vedic-inspired Event Based Context Aware Feature, Zone, Action, and State Machine integrated Artificial Intelligence Framework",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"license": "VLA:23221940810208468106 LICENSE.md",
|