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
是一个非 null 通知名称,可以属于特定的命名空间,就像任何IReactPropertyName
一样。dispatcher
用于调用通知处理程序。如果它为 null,则同步调用处理程序。handler
是一个可以实现为 lambda 的委托,用于处理通知。该方法返回一个IReactNotificationSubscription
,在订阅活动期间必须保持其活动状态。当IReactNotificationSubscription
被销毁时,订阅将被移除。