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