forked from nightscout/nightscout-connect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.js
39 lines (30 loc) · 923 Bytes
/
demo.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
const { createMachine, Machine, actions, interpret, spawn } = require('xstate');
var testImpl = require('./testable_driver');
var axios = require('axios');
var builder = require('./lib/builder');
function demoLoop ( ) {
var output = require('./lib/outputs')( )( );
var make = builder({ output });
var impl = testImpl.fakeFrame({ }, axios);
impl.generate_driver(make);
var built = make( );
// console.log("BUILDER OUTPUT", built);
console.log("BUILDER OUTPUT", JSON.stringify(built, null, 2));
return built;
}
function main ( ) {
var things = demoLoop( );
console.log(things);
var actor = interpret(things);
actor.start( );
actor.send({type: 'START'});
setTimeout(( ) => {
actor.send({type: 'STOP'});
}, 60000 * 5);
}
if (!module.parent) {
main( );
}
module.exports.command = 'demo';
exports.describe = 'a quick demo using timers instead of I/O';
module.exports.handler = main;