Skip to content

Instantly share code, notes, and snippets.

@dtchepak
Last active January 4, 2016 07:19
Show Gist options
  • Save dtchepak/8587433 to your computer and use it in GitHub Desktop.
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)
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