Skip to content

Instantly share code, notes, and snippets.

@Kudo
Created November 5, 2018 16:21
Show Gist options
  • Save Kudo/53e1d276a91987eee7d61713bc897775 to your computer and use it in GitHub Desktop.
Save Kudo/53e1d276a91987eee7d61713bc897775 to your computer and use it in GitHub Desktop.
CxxModule exports method bar() that will send JS event to simulate AppState changes
auto HelloCxxModule::getMethods() -> std::vector<Method> {
return {
Method("bar",
[this]() {
if (auto reactInstance = getInstance().lock()) {
reactInstance->callJSFunction(
"RCTDeviceEventEmitter", "emit",
folly::dynamic::array(
"appStateDidChange",
folly::dynamic::object("app_state", "active")));
}
}),
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment