mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Decouple GuardedRunnable + friends from ReactContext
Summary: Step 1 in removing the dependency on ReactContext from GuardedRunnable and other related classes. These are extensively by native modules and view managers, so in order to remove the bridge dependency from those modules we'll need to first decouple these classes from ReactContext. It turns out they only need ReactContext for its handleException method, which delegates out to product code. For backwards compatibility I'm exposing another NativeModuleExceptionManager in ReactContext that simply wraps its handleException method (since this interface already does everything we need). I figured I'd keep around an extra constructor that still uses ReactContext for now instead of trying to migrate everything over at once. Reviewed By: makovkastar Differential Revision: D16270995 fbshipit-source-id: c9a8714bea7ac2a98e78234a0bae49140c00980d
This commit is contained in:
committed by
Facebook Github Bot
parent
3a825c0360
commit
83969c26fb
@@ -6,15 +6,21 @@
|
||||
*/
|
||||
package com.facebook.react.fabric;
|
||||
|
||||
import com.facebook.react.bridge.NativeModuleCallExceptionHandler;
|
||||
import com.facebook.react.bridge.ReactContext;
|
||||
import com.facebook.react.modules.core.ChoreographerCompat;
|
||||
|
||||
public abstract class GuardedFrameCallback extends ChoreographerCompat.FrameCallback {
|
||||
|
||||
private final ReactContext mReactContext;
|
||||
private final NativeModuleCallExceptionHandler mExceptionHandler;
|
||||
|
||||
@Deprecated
|
||||
protected GuardedFrameCallback(ReactContext reactContext) {
|
||||
mReactContext = reactContext;
|
||||
this(reactContext.getExceptionHandler());
|
||||
}
|
||||
|
||||
protected GuardedFrameCallback(NativeModuleCallExceptionHandler exceptionHandler) {
|
||||
mExceptionHandler = exceptionHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -22,7 +28,7 @@ public abstract class GuardedFrameCallback extends ChoreographerCompat.FrameCall
|
||||
try {
|
||||
doFrameGuarded(frameTimeNanos);
|
||||
} catch (RuntimeException e) {
|
||||
mReactContext.handleException(e);
|
||||
mExceptionHandler.handleException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user