one
Version:
One is a React framework for web, iOS, and Android apps.
22 lines (19 loc) • 881 B
JavaScript
import { NativeEventEmitter, NativeModules } from "react-native";
import { callNativeSource } from "./index.native.js";
import { decodeNativeSourceCallback } from "./wire.native.js";
var emitter = new NativeEventEmitter(NativeModules.OneNativeSourceEvents);
function subscribeNativeSourceEvent(module, event, listener, contractHash, payloadWires, structs) {
if (typeof listener !== "function") {
throw new TypeError(`native event ${module}.${event} needs a listener function`);
}
var channel = `OneNativeSource.${module}.${event}`;
var subscription = emitter.addListener(channel, function(args) {
listener(...decodeNativeSourceCallback(args, payloadWires, structs, event));
});
callNativeSource(module, event, [], contractHash);
return function() {
return subscription.remove();
};
}
export { subscribeNativeSourceEvent };
//# sourceMappingURL=events.native.js.map