Revisions
-
mattpodwysocki renamed this gist
Jul 9, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
mattpodwysocki revised this gist
Jul 9, 2014 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains 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 @@ -40,9 +40,9 @@ }, observer.onError.bind(observer), function () { // Don't want to prematurely stop the outer if the inner is still going isStopped = true; if (!hasCurrent && g.length === 1) { observer.onCompleted(); } })); -
jhusain revised this gist
Jul 9, 2014 . 1 changed file with 22 additions and 18 deletions.There are no files selected for viewing
This file contains 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 @@ -7,41 +7,45 @@ var sources = this; return new AnonymousObservable(function (observer) { var hasCurrent = false, isStopped = false, m = new SingleAssignmentDisposable(), g = new CompositeDisposable(); g.add(m); m.setDisposable(sources.subscribe( function (innerSource) { if (!hasCurrent) { hasCurrent = true; isPromise(innerSource) && (innerSource = observableFromPromise(innerSource)); var innerSubscription = new SingleAssignmentDisposable(); g.add(innerSubscription); innerSubscription.setDisposable(innerSource.subscribe( observer.onNext.bind(observer), function(e) { hasCurrent = false; observer.onError(e); }, function () { g.remove(innerSubscription); hasCurrent = false; if (isStopped && g.length === 1) { observer.onCompleted(); } )); } }, observer.onError.bind(observer), function () { hasCurrent = false; isStopped = true; if (g.length === 1) { observer.onCompleted(); } })); return g; }); -
mattpodwysocki created this gist
Jul 8, 2014 .There are no files selected for viewing
This file contains 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,48 @@ /* * Performs a exclusive waiting for the first to finish before subscribing to another observable. * Observables that come in between subscriptions will be dropped on the floor. * @returns {Observable} A exclusive observable with only the results that happen when subscribed. */ observableProto.exclusive = function () { var sources = this; return new AnonymousObservable(function (observer) { var hasCurrent = false, isStopped = true, m = new SingleAssignmentDisposable(), g = new CompositeDisposable(); if (!hasCurrent) { hasCurrent = true; g.add(m); m.setDisposable(sources.subscribe( function (innerSource) { isPromise(innerSource) && (innerSource = observableFromPromise(innerSource)); var innerSubscription = new SingleAssignmentDisposable(); g.add(innerSubscription); innerSubscription.setDisposable(innerSource.subscribe( observer.onNext.bind(observer), observer.onError.bind(onError), function () { g.remove(innerSubscription); if (isStopped && !hasCurrent && g.length === 1) { observer.onCompleted(); } )); }, observer.onError.bind(observer), function () { hasCurrent = false; isStopped = true; if (g.length === 1) { observer.onCompleted(); } })); } return g; }); };