gun/examples/angular/src/app/gun.helper.ts
Victor Noël 141b5ea390 Bump gun to 0.7.3
Add val$ and on$ to get observables (on$ can't be unsubscribed for
now...)
2017-04-22 11:28:00 +02:00

19 lines
477 B
TypeScript

import { Observable } from 'rxjs/Observable';
import { Gun } from 'gun/gun';
export function on$(node): Observable<any> {
return Observable.fromEventPattern(
// note: passing directly node.on doesn't seem to work...
h => node.on(v => h(v)),
// TODO this is incorrect
(_, s) => s.off()
);
}
export function val$(node): Observable<any> {
return new Observable(o => node.val(v => {
o.next(v);
o.complete();
}));
}