What is the action returned by the subscribe parameter for IObservable.Create in fact?

The definition of the IObservable.Create method:

public static IObservable<TSource> Create<TSource>( Func<IObserver<TSource>, Action> subscribe ) 

I get the function to be called after signing the observable, where I can then call OnNext, OnError and OnComplete on the observer. But why should I return the action from the subscibe parameter and when will it be called?

+4
source share
3 answers

It is called when unsubscribing from an observer. Source

+4
source

It is called when a subscription is placed. It is designed for you so that you can manage any resources that you have allocated.

+1
source

In response to Kent's response, calling Create equivalent to calling CreateWithDisposable with the action passed to Disposable.Create()

+1
source

Source: https://habr.com/ru/post/1333083/


All Articles