diff options
| author | Ben Beltran <ben@nsovocal.com> | 2018-04-21 02:49:42 -0500 |
|---|---|---|
| committer | Ben Beltran <ben@nsovocal.com> | 2018-04-21 02:49:42 -0500 |
| commit | 4908bfb50681ed410dc557005033959457e05d2f (patch) | |
| tree | dfdf1debf302708ba0ff0621a540e9bc7bcb20ed /lib | |
| parent | 7ae9e9d69e017ec785708c4470c682395a718a5f (diff) | |
Emit events
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/serpentity/node_collection.js | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/serpentity/node_collection.js b/lib/serpentity/node_collection.js index 8da41da..bb66a8d 100644 --- a/lib/serpentity/node_collection.js +++ b/lib/serpentity/node_collection.js @@ -1,5 +1,7 @@ 'use strict'; +const Events = require('events'); + /* * Node Collections contain nodes, in order to keep the lists of nodes * that belong to each type. @@ -8,7 +10,7 @@ * instances of that class. */ -const NodeCollection = class NodeCollection { +const NodeCollection = class NodeCollection extends Events { constructor(config) { @@ -39,6 +41,7 @@ const NodeCollection = class NodeCollection { } this.nodes.push(node); + this.emit('nodeAdded', { node }); return true; } @@ -65,6 +68,7 @@ const NodeCollection = class NodeCollection { if (found) { this.nodes.splice(foundIndex, 1); + this.emit('nodeRemoved', { node }); } return found; |