Last active
May 10, 2025 03:56
-
-
Save seanislegend/94b3b0bd70b6d9d1af2c to your computer and use it in GitHub Desktop.
Revisions
-
seanislegend revised this gist
Sep 17, 2015 . 1 changed file with 11 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,9 @@ let timeout = 1000; /** * Create a custom observable that creates a XHR request and returns complete when the promise is fulfilled */ let observable = Rx.Observable.create((o) => { dataService.fetch('test.json') .then((data) => { o.onNext(data); @@ -12,11 +14,15 @@ let dataObservable = Rx.Observable.create((o) => { /** * Call our observable immediately and then add an interval for the polled requests */ let source = observable .take(1) .merge( Rx.Observable .interval(timeout) .flatMapLatest(observable) ) -
seanislegend revised this gist
Sep 15, 2015 . 1 changed file with 0 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,9 +11,6 @@ let dataObservable = Rx.Observable.create((o) => { }); /** * Use our observable and call every 2 seconds. */ -
seanislegend revised this gist
Sep 15, 2015 . 1 changed file with 8 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -12,11 +12,15 @@ let dataObservable = Rx.Observable.create((o) => { /** * Use our observable and call every 2 seconds. */ /** * Use our observable and call every 2 seconds. */ let source = Rx.Observable .interval(this.options.timeout) .flatMapLatest(() => this.observer); /** -
seanislegend created this gist
Sep 15, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ /** * Create a custom observable that creates a XHR request and returns complete when the promise is fulfilled */ let dataObservable = Rx.Observable.create((o) => { dataService.fetch('test.json') .then((data) => { o.onNext(data); o.onCompleted(); }) .fail(o.onError); }); /** * Use our observable and call every 2 seconds. Repeat ensure it continues to be called. */ let source = dataObservable .sample(2000) .repeat(); /** * Return events from the observable. */ source.subscribe( (data) => console.log(data), (error) => console.log(error), () => console.log('done') );