Created
August 25, 2011 11:49
-
-
Save cburgdorf/1170494 to your computer and use it in GitHub Desktop.
cachedObservable
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 characters
//This doesnt work (Fails on second try) | |
var cachedObservable; | |
var observableFms = Rx.Observable.If(function() { | |
return cachedObservable !== undefined; | |
}, | |
cachedObservable, | |
Rx.Observable.Defer(function() { | |
cachedObservable = service.getObservableFmsAuswertungForTour(data.ID); | |
return cachedObservable; | |
})); | |
//This does work | |
var cachedObservable; | |
var observableFms = Rx.Observable.If(function() { | |
return cachedObservable !== undefined; | |
}, | |
Rx.Observable.Defer(function(){ | |
return cachedObservable; | |
}, | |
Rx.Observable.Defer(function() { | |
cachedObservable = service.getObservableFmsAuswertungForTour(data.ID); | |
return cachedObservable; | |
})); | |
What's wrong with the first one? Even I can see in the debugger that the cachedObservable was set correctly from the first call, the second call fails with "undefined has no method Subscribe". The second approach does work however. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment