dpaw-monorail-plugin
Version:
JS library to link the brocket network to the QGIS/monorail server
34 lines (27 loc) • 676 B
JavaScript
/**
* @fileOverview
* @name model.js
* @author Gavin Coombes
* @license BSD-3-Clause
*/
let Rx = require('rx');
let u = require('dpaw-brocket-utility');
let log = u.log;
let Obs = Rx.Observable;
function model(actions) {
let incoming$ = actions.incoming$;
let messageArr$ = incoming$
.do(msg => log('Monorail.plugin: incoming msg', msg))
.pluck('payload')
.scan(myAggregate, [])
.startWith(['in the beginning']);
let state$ = Obs.combineLatest(
messageArr$, messageArr => ({ messageArr })
);
return state$;
}
module.exports = model;
function myAggregate(acc, val, ix, src) {
acc.push(val);
return acc.slice(-10);
}