Skip to content

Commit

Permalink
Prevent against actions before attaching to bridge
Browse files Browse the repository at this point in the history
  • Loading branch information
Ethan Perez committed Sep 17, 2019
1 parent b6b48fc commit eb3f791
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,32 @@ public static KeyEventModule getInstance() {
}

public void onKeyDownEvent(int keyCode, KeyEvent keyEvent) {
if (!mReactContext.hasActiveCatalystInstance()) {
return;
}

if (mJSModule == null) {
mJSModule = mReactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class);
}
mJSModule.emit("onKeyDown", getJsEventParams(keyCode, keyEvent, null));
};

public void onKeyUpEvent(int keyCode, KeyEvent keyEvent) {
if (!mReactContext.hasActiveCatalystInstance()) {
return;
}

if (mJSModule == null) {
mJSModule = mReactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class);
}
mJSModule.emit("onKeyUp", getJsEventParams(keyCode, keyEvent, null));
};

public void onKeyMultipleEvent(int keyCode, int repeatCount, KeyEvent keyEvent) {
if (!mReactContext.hasActiveCatalystInstance()) {
return;
}

if (mJSModule == null) {
mJSModule = mReactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class);
}
Expand Down

0 comments on commit eb3f791

Please sign in to comment.