|
@@ -0,0 +1,48 @@
|
|
|
+# Context
|
|
|
+
|
|
|
+What is a eventual context?
|
|
|
+
|
|
|
+Eventual context is basically an entry that can be destroyed with all underlying information:
|
|
|
+
|
|
|
+```javascript
|
|
|
+
|
|
|
+ var eventual = new Eventual();
|
|
|
+
|
|
|
+ var ctx = eventual.createContext();
|
|
|
+ var ctx2 = eventual.createContext();
|
|
|
+
|
|
|
+ // This will store the listener in the ctx
|
|
|
+ ctx.on('chan:chan2:chan3',() =>{
|
|
|
+ console.log("received");
|
|
|
+ });
|
|
|
+
|
|
|
+ ctx2.on('chan:chan2:chan3',() => {
|
|
|
+ console.log("fire");
|
|
|
+ });
|
|
|
+
|
|
|
+ // This should fire events, and 'received' and 'fire' will be printed
|
|
|
+ //eventual.emit('chan:chan2:chan3');
|
|
|
+ ctx2.emit('chan:chan2:chan3');
|
|
|
+
|
|
|
+ ctx.destroy();
|
|
|
+
|
|
|
+ // Will only print 'fire'
|
|
|
+ ctx2.emit('chan:chan2:chan3');
|
|
|
+
|
|
|
+```
|
|
|
+
|
|
|
+### How it works:
|
|
|
+
|
|
|
+After context creation the context will be pushed into the eventual registry
|
|
|
+each eventual context or channels will maintain a eventual reference.
|
|
|
+
|
|
|
+method destroy is an alias for eventual.destroyContext() it will remove itself from the registry
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|