gpt4 book ai didi

javascript - React native 模块向 javascript 文档发送事件是否正确?

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:00:47 25 4
gpt4 key购买 nike

在 facebook 的 doc它说

- (void)calendarEventReminderReceived:(NSNotification *)notification
{
NSString *eventName = notification.userInfo[@"name"];
[self.bridge.eventDispatcher sendAppEventWithName:@"EventReminder"
body:@{@"name": eventName}];
}

JavaScript 代码可以订阅这些事件:

var subscription = DeviceEventEmitter.addListener(
'EventReminder',
(reminder) => console.log(reminder.name)
);

但我永远无法完成这项工作。这应该改为 sendDeviceEventWithName 吗?原生模块也应该始终是单例的吗?

最佳答案

目前,没有。请看这个问题:

https://github.com/facebook/react-native/issues/394

Changing the example Objective-C to call sendDeviceEventWithName instead of sendAppEventWithName fixes the problem.

这似乎证实了您的建议。有一个等待合并的拉取请求:

https://github.com/facebook/react-native/pull/530

关于javascript - React native 模块向 javascript 文档发送事件是否正确?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29424913/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com