James L
James L

Reputation: 16874

RX syntax to wait until particular value is received, take that, and then unsubscribe?

I am waiting for a particular value in a stream, at which point, I want to do some work in my subscriber and also unsubscribe from the ongoing stream. What is the best syntax for doing that?

Upvotes: 1

Views: 687

Answers (1)

James World
James World

Reputation: 29796

Something like this:

var value = stream.Where(/* predicate to select value of interest */)
                  .Take(1)
                  .Subscribe(value => /* do work */);

Upvotes: 8

Related Questions