You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If the value generated by an Observable.computed (on read) is a Promise, we should notify its listeners only after the Promise has been fulfilled. This will open various possibilities when used in combination with Observable#map, i.e.
Actually, that won't work and would require a huge amount of hacking. There's a better way to do it, though:
Add AsyncObservable, which is similar to a calculated observable expect that it notifies its listeners only after its value has been resolved. There should not be automatic dependency management for this type of observable (unlike ComputedObservable).
Usage:
varurl=Observable('/foo.json');url.async(function(urlObservable){// we pass in the observable, not its value, to allow lazy evaluation// in case its a computed observablereturnxhrPromise(urlObservable.get());}).map(function(content){returnJSON.parse(content);});
Such an AsyncObservable starts with a value of null and is expected to return a Promise. Once that Promise is resolved, it will store the value and notify the listeners. If its dependency changes while a computation promise is running, it will ignore those changes. Maybe add an option to reevaluate the value once the running promise is resolved.
Primary use case: Make it much easier to delay the computation of an observable (i.e. to do so only on an animation frame).
If the value generated by an Observable.computed (on read) is a Promise, we should notify its listeners only after the Promise has been fulfilled. This will open various possibilities when used in combination with Observable#map, i.e.
The text was updated successfully, but these errors were encountered: