Last active
January 4, 2016 07:19
-
-
Save dtchepak/8587433 to your computer and use it in GitHub Desktop.
Rather than explicitly unsubscribing observers, is building completion into all observables a good idea? (For observables that don't naturally complete; streams of mouse moves, driver events etc)
This file contains hidden or 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
var done = new Subject<Unit>(); | |
var status = Observable | |
.Interval(TimeSpan.FromMilliseconds(450)) | |
.Select(_ => driver.Status()) // driver keep-alive | |
.TakeUntil(done); | |
// On dispose, window close, etc... | |
done.CompletedWith(Unit.Value); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment