syndicate-2017/js/examples/smoketest/index.js

34 lines
695 B
JavaScript

"use strict";
var G;
$(document).ready(function () {
var Dataspace = Syndicate.Dataspace;
var sub = Syndicate.sub;
var __ = Syndicate.__;
var _$ = Syndicate._$;
G = new Syndicate.Ground(function () {
console.log('starting ground boot');
Dataspace.spawn({
counter: 0,
boot: function () {},
handleEvent: function (e) {},
step: function () {
Dataspace.send(["beep", this.counter++]);
return this.counter <= 10;
}
});
Dataspace.spawn({
boot: function () { return sub(["beep", __]); },
handleEvent: function (e) {
if (e.type === 'message') {
console.log("beep!", e.message[1]);
}
}
});
});
G.startStepping();
});