Support Network onStateChange callback.
This commit is contained in:
parent
d00d205314
commit
f06d951dcb
|
@ -11,5 +11,6 @@
|
|||
<h1>jQuery example</h1>
|
||||
<button id="clicker">Click me</button>
|
||||
<div id="result">0</div>
|
||||
<pre id="spy-holder"></pre>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -24,5 +24,8 @@ $(document).ready(function () {
|
|||
}
|
||||
});
|
||||
});
|
||||
G.network.onStateChange = function (mux, patch) {
|
||||
$("#spy-holder").text(Syndicate.prettyTrie(mux.routingTable));
|
||||
};
|
||||
G.startStepping();
|
||||
});
|
||||
|
|
|
@ -36,6 +36,7 @@ function Network(bootFn) {
|
|||
this.processTable = Immutable.Map(); // pid -> Behavior
|
||||
this.runnablePids = Immutable.Set(); // of pid
|
||||
this.mux = new Mux.Mux();
|
||||
this.onStateChange = function (mux, deltaAggregate) {};
|
||||
this.asChild('meta', function () { return bootFn() }, true);
|
||||
}
|
||||
|
||||
|
@ -273,6 +274,7 @@ Network.prototype.deliverPatches = function (oldMux, updateStreamResult) {
|
|||
self.deliverEvent(pid, stateChange(patch));
|
||||
});
|
||||
events.metaEvents.forEach(Network.stateChange);
|
||||
this.onStateChange(this.mux, updateStreamResult.deltaAggregate);
|
||||
};
|
||||
|
||||
Network.prototype.deliverEvent = function (pid, event) {
|
||||
|
|
Loading…
Reference in New Issue