Rx subscriptions and garbage collection

Viewed 1548

Do you need to assign the IDisposable returned by IObservable.Subscribe to a variable in order to protect the subscription from being garbage collected, or is the presence of an active subscription enough?

My use case: I create a one-shot observable from an existing observable (myObservable in the example):

myObservable.Take(1).Subscribe(fun v -> printfn "One-shot: %A" v) |> ignore
2 Answers
Related