-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
disposing an observable should dispose its rxObservable #6
base: master
Are you sure you want to change the base?
Conversation
just looked a bit more at this, it would also be good if the knockout observable only subscribed to the underlying rx observable when it is subscribed to.
I'm guessing the same applies vice versa too |
Thanks for PR, you're the first! 👍
KO's observable doesn't provide var rxObs = new Rx.Subject();
var koObs = rxObs.toKoObservable();
assert.ok(koObs() === undefined, "value wasn't set yet");
rxObs.onNext(1);
assert.equal(koObs(), 1); Your code will fail the test, because there's no KO's subscriptions yet.
Igor |
ah that's true - however if the rx observable is a cold observable and it isn't subscribed to until the ko observable is subscribed to then it won't produce any values until the ko observable subscribes. I'm not sue about subjects tbh - I don't use them just rx.Observable.create. Maybe it's a special case but it works for what I am doing where the underlying rx observable listens to a web api and subscribes to signalr endpoint when ko observable is active and then unsubscribes to signlar when disposed. its a bit llike ko.computed vs ko.purecomputed I wonder if there could be an alternative to rx2koObservable say coldRx2koObservable which do0es the above. best wishes |
ps my first foray into typescript (only hacking your code :P) |
No description provided.