calog/examples/scripts/multifile/producer.js

18 lines
806 B
JavaScript

// producer.js -- one half of a MULTI-FILE calog run (see consumer.lua).
//
// Run BOTH files together, in one process:
// bin/calog examples/scripts/multifile/producer.js examples/scripts/multifile/consumer.lua
//
// Files listed on the command line run CONCURRENTLY and share one runtime -- so this
// JavaScript file and the Lua file talk through the same kv store and pubsub bus.
// This side writes the shared data, then signals "ready" after a short delay (giving the
// consumer, loaded from the other file, time to subscribe first).
kvSet("greeting", "Hello");
kvSet("from", "JavaScript (producer.js)");
calogPrint("producer.js: wrote greeting + from into the shared kv store");
timerAfter(300, function () {
calogPrint("producer.js: signalling 'ready'");
psPublish("ready", "go");
});