Add API to reset CxxModuleWrapper's module pointer

Reviewed By: mhorowitz

Differential Revision: D4914335

fbshipit-source-id: f28f57c2e74d590dacfb85d8027747837f768fdc
This commit is contained in:
Pieter De Baets 2017-04-20 10:59:59 -07:00 committed by Facebook Github Bot
parent db8efd9c4b
commit 17020ff9af
1 changed files with 8 additions and 1 deletions

View File

@ -2,7 +2,6 @@
package com.facebook.react.cxxbridge;
import java.util.Map;
import com.facebook.jni.HybridData;
import com.facebook.proguard.annotations.DoNotStrip;
@ -52,4 +51,12 @@ public class CxxModuleWrapperBase implements NativeModule
protected CxxModuleWrapperBase(HybridData hd) {
mHybridData = hd;
}
// Replace the current native module held by this wrapper by a new instance
protected void resetModule(HybridData hd) {
if (hd != mHybridData) {
mHybridData.resetNative();
mHybridData = hd;
}
}
}