如何将 React Native 事件从 JavaScript 发送到 JavaScript
How to Send React Native Events to JavaScript from JavaScript
使用 React Native,我可以根据 official React Native Native Modules documentation 从原生模块调度事件。但是如何从 JavaScript 发送事件?
http://facebook.github.io/react-native/docs/nativemodulesios.html#sending-events-to-javascript
我无法正确理解你的问题!!
Provide code!
也许你正在寻找这样的东西:
var EventEmitter = require('events').EventEmitter;
var server = new EventEmitter();
server.on('foo', function() {
console.log('got foo');
});
server.emit('foo');
检查这个拉:
您可以像这样从 JavaScript 发送 React Native 事件:
import { NativeEventEmitter, NativeModules } from "react-native";
const nativeEventEmitter = new NativeEventEmitter(NativeModules.Emitter);
nativeEventEmitter.emit("Event Name");
使用 React Native,我可以根据 official React Native Native Modules documentation 从原生模块调度事件。但是如何从 JavaScript 发送事件?
http://facebook.github.io/react-native/docs/nativemodulesios.html#sending-events-to-javascript
我无法正确理解你的问题!!
Provide code!
也许你正在寻找这样的东西:
var EventEmitter = require('events').EventEmitter;
var server = new EventEmitter();
server.on('foo', function() {
console.log('got foo');
});
server.emit('foo');
检查这个拉:
您可以像这样从 JavaScript 发送 React Native 事件:
import { NativeEventEmitter, NativeModules } from "react-native";
const nativeEventEmitter = new NativeEventEmitter(NativeModules.Emitter);
nativeEventEmitter.emit("Event Name");