IReactNotificationService
类型:接口
通知服务,可用于在应用程序的不同组件之间发送通知。使用 Subscribe
方法订阅通知,使用 SendNotification
方法发送通知。
方法
SendNotification
void SendNotification
(IReactPropertyName
notificationName, Object sender, Object data)
发送带 notificationName
的通知。
notificationName
是要发送的通知的名称。它不能为 null。sender
是发送通知的对象。它可以为 null。data
是与通知相关联的数据。它可以为 null。考虑使用IReactPropertyBag
发送半结构化数据。可以使用ReactPropertyBagHelper.CreatePropertyBag
方法创建它。
Subscribe
IReactNotificationSubscription
Subscribe
(IReactPropertyName
notificationName, IReactDispatcher
dispatcher, ReactNotificationHandler
handler)
订阅通知。
notificationName
是一个非空的通知名称,可以属于一个特定的命名空间,就像任何IReactPropertyName
一样。dispatcher
用于调用通知处理程序。如果它为 null,则处理程序将同步调用。handler
是一个委托,可以作为 lambda 实现来处理通知。该方法返回一个IReactNotificationSubscription
,必须在订阅活动期间保持其活动状态。当IReactNotificationSubscription
被销毁时,订阅将被移除。