何时以及为何使用Notification类? [英] When and why to use the Notification class?
问题描述
大家好,
我试图了解何时以及为何使用Notification类。我发现它与ToNotifier和FromNotifier有关,但不完全确定它们的用途。
它是否用于创建一个双向方式,如可观察序列和观察者之间的绑定,所以观察者可以通过向原始观察者的通知推回更改,或者?
谢谢,Egil。
Hi Egil,
通知< T> 类表示可观察序列 部分的概括 - 所有值(OnNext),完成(OnCompleted)和错误(OnError)消息是通知。您可以使用
取消实现和实体化运算符将序列转换为广义形式或从广义形式转换序列。请参阅Lee的优秀
中的相应部分
简介Rx。
ToNotifier 方法将观察者对象转换为等效方法。您不需要实施
IObserver< T> 界面,而是提供接受
通知< T> 的方法。
观察者和观察者之间的关系总是单向的。
J。乙
Hi all,
I am trying to understand when and why to use the Notification class. I see it is related to ToNotifier and FromNotifier, but not sure entirely of their use.
Is it for creating a two way like binding between a an observable sequence and the observer, so the observer can push changes back with notifications to the originating observable, or?
Thanks, Egil.
Hi Egil,
the Notification<T> class represents a generalization of observable sequence parts - all values (OnNext), completion (OnCompleted), and error (OnError) messages are notifications. You can use Dematerialize and Materialize operators to convert a sequence to and from the generalized form. See a corresponding section in Lee's excellent Intro to Rx.
The ToNotifier method converts observer object to an equivalent method. Instead of class implementing IObserver<T> interface, you provide method accepting Notification<T>.
The relationship between observable and observer are always one-way.
J. B.
这篇关于何时以及为何使用Notification类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!