Skip to content

Breaking: Update react-native-threads for RN 0.70+ API changes #156

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ios/RNThread.podspec → RNThread.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'json'

package = JSON.parse(File.read(File.join(__dir__, '../package.json')))
package = JSON.parse(File.read(File.join(__dir__, './package.json')))

Pod::Spec.new do |s|
s.name = "RNThread"
Expand All @@ -11,7 +11,7 @@ Pod::Spec.new do |s|
s.author = package['author']
s.homepage = "https://github.com/joltup/RNThread.git"
s.source = { :git => "https://github.com/joltup/RNThread.git", :tag => s.version }
s.source_files = "**/*.{h,m}"
s.source_files = "ios/**/*.{h,m}"
s.platform = :ios, "7.0"
s.tvos.deployment_target = '10.0'

Expand Down
12 changes: 6 additions & 6 deletions android/src/main/java/com/reactlibrary/ReactContextBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import com.facebook.react.bridge.JavaScriptExecutorFactory;
import com.facebook.react.jscexecutor.JSCExecutorFactory;
import com.facebook.react.bridge.JavaScriptExecutor;
import com.facebook.react.bridge.NativeModuleCallExceptionHandler;
import com.facebook.react.bridge.JSExceptionHandler;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.ReactInstanceManager;
import com.facebook.react.bridge.queue.ReactQueueConfigurationSpec;
Expand Down Expand Up @@ -76,7 +76,7 @@ public ReactApplicationContext build() throws Exception {
// fresh new react context
final ReactApplicationContext reactContext = new ReactApplicationContext(parentContext);
if (devSupportManager != null) {
reactContext.setNativeModuleCallExceptionHandler(devSupportManager);
reactContext.setJSExceptionHandler(devSupportManager);
}

// load native modules
Expand All @@ -88,9 +88,9 @@ public ReactApplicationContext build() throws Exception {
.setJSExecutor(jsExecutor)
.setRegistry(nativeRegistryBuilder.build())
.setJSBundleLoader(jsBundleLoader)
.setNativeModuleCallExceptionHandler(devSupportManager != null
.setJSExceptionHandler(devSupportManager != null
? devSupportManager
: createNativeModuleExceptionHandler()
: createJSExceptionHandler()
);


Expand Down Expand Up @@ -132,8 +132,8 @@ public Object call() throws Exception {
return reactContext;
}

private NativeModuleCallExceptionHandler createNativeModuleExceptionHandler() {
return new NativeModuleCallExceptionHandler() {
private JSExceptionHandler createJSExceptionHandler() {
return new JSExceptionHandler() {
@Override
public void handleException(Exception e) {
throw new RuntimeException(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@
import com.facebook.react.modules.core.ExceptionsManagerModule;
import com.facebook.react.modules.core.TimingModule;
import com.facebook.react.modules.debug.SourceCodeModule;
import com.facebook.react.modules.deviceinfo.DeviceInfoModule;
import com.facebook.react.modules.intent.IntentModule;
import com.facebook.react.modules.network.NetworkingModule;
import com.facebook.react.modules.storage.AsyncStorageModule;
import com.facebook.react.modules.systeminfo.AndroidInfoModule;
import com.facebook.react.modules.vibration.VibrationModule;
import com.facebook.react.modules.websocket.WebSocketModule;
import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.ViewManager;
import com.facebook.react.modules.debug.DevSettingsModule;

Expand All @@ -38,12 +39,12 @@ public List<NativeModule> createNativeModules(ReactApplicationContext catalystAp
new ExceptionsManagerModule(reactInstanceManager.getDevSupportManager()),
new AppStateModule(catalystApplicationContext),
new TimingModule(catalystApplicationContext, reactInstanceManager.getDevSupportManager()),
new UIManagerStubModule(catalystApplicationContext),
new UIManagerModule(catalystApplicationContext, reactInstanceManager.getOrCreateViewManagers(catalystApplicationContext), -1),
new DeviceInfoModule(catalystApplicationContext),
new SourceCodeModule(catalystApplicationContext),
new JSCHeapCapture(catalystApplicationContext),

// Main list
new AsyncStorageModule(catalystApplicationContext),
new IntentModule(catalystApplicationContext),
new NetworkingModule(catalystApplicationContext),
new VibrationModule(catalystApplicationContext),
Expand Down
9 changes: 7 additions & 2 deletions ios/ThreadManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,18 @@ @implementation ThreadManager

int threadId = abs(arc4random());

NSURL *threadURL = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:name fallbackResource:name];
NSURL *threadURL = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:name fallbackURLProvider:^NSURL * {
return [[NSBundle mainBundle] URLForResource:name withExtension:@"jsbundle"];
}];
NSLog(@"starting Thread %@", [threadURL absoluteString]);


RCTBridge *threadBridge = [[RCTBridge alloc] initWithBundleURL:threadURL
RCTBridge* currentBridge = RCTBridge.currentBridge;
RCTBridge *threadBridge = [[RCTBridge alloc] initWithBundleURL:threadURL
moduleProvider:nil
launchOptions:nil];
RCTBridge.currentBridge = currentBridge;


ThreadSelfManager *threadSelf = [threadBridge moduleForName:@"ThreadSelfManager"];
[threadSelf setThreadId:threadId];
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
"android/",
"ios/",
"js/",
"index.js"
"index.js",
"react-native.config.js",
"RNThread.podspec"
],
"peerDependencies": {
"react-native": ">=0.50.0"
Expand Down