canjs / can-simple-observable

Create an observable value.
https://canjs.com/doc/can-simple-observable.html
MIT License
3 stars 1 forks source link

AsyncObservable cannot return a value after previously resolving #13

Open phillipskevin opened 6 years ago

phillipskevin commented 6 years ago

An AsyncObservable cannot return a value from its getter if resolve has already been called.

That means the observable below cannot be used to toggle from 0 to 1 and then back to 0:

    var asyncObs = new AsyncObservable(function(lastSet, resolve){
        if (value.get() === 1) {
            resolve(1);
        }

        return 0;
    });
phillipskevin commented 6 years ago

Maybe what is strange about this is that the value ever becomes 1, since even when you resolve(1) you also then return 0.