git ssb

3+

dangerousbeans / scuttle-vue



Tree: 5d3463a5a812931815b799819ca80c8f2119bda2

Files: 5d3463a5a812931815b799819ca80c8f2119bda2 / src / plugins / source_observer.js

679 bytesRaw
1var SourceObserver = {};
2var pull = require('pull-stream')
3import Rx from 'rxjs/RX'
4import { Observable } from 'rxjs/Observable'
5
6// safe nul checking thing
7const nn = require('nevernull');
8
9
10SourceObserver.install = function(Vue, options){
11 var observers = {
12 accumulated_observable(source){
13 return Rx.Observable.create(function (observer) {
14 pull(
15 source,
16 pull.drain(msg => observer.next(msg))
17 )
18 }).scan((accumulator, newMsg) => [nn(newMsg), ...accumulator], [])
19 },
20 cb_obs(f, args){
21 return Rx.Observable.bindCallback(f)(args)
22 }
23 }
24
25 Vue.prototype.$observers = observers;
26};
27
28export default SourceObserver;
29

Built with git-ssb-web