mirror of
https://github.com/amark/gun.git
synced 2025-06-10 16:16:49 +00:00
19 lines
477 B
TypeScript
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();
|
|
}));
|
|
}
|