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被销毁时,订阅将被移除。