support react-native version 0.10.0
This commit is contained in:
parent
7ac7ab3c94
commit
1148ac5417
|
@ -23,5 +23,4 @@
|
|||
@protocol RCTBridgeModule;
|
||||
|
||||
@interface Realm : NSObject <RCTBridgeModule>
|
||||
|
||||
@end
|
||||
|
|
|
@ -24,9 +24,10 @@
|
|||
@import RealmJS;
|
||||
@import JavaScriptCore;
|
||||
|
||||
@protocol RCTJavaScriptContext
|
||||
@interface RCTJavaScriptContext : NSObject <RCTInvalidating>
|
||||
@property (nonatomic, assign, readonly) JSGlobalContextRef ctx;
|
||||
- (void)executeBlockOnJavaScriptQueue:(dispatch_block_t)block;
|
||||
- (instancetype)initWithJSContext:(JSGlobalContextRef)context;
|
||||
@end
|
||||
|
||||
RCT_EXTERN id<RCTJavaScriptExecutor> RCTGetLatestExecutor(void);
|
||||
|
@ -41,16 +42,24 @@ RCT_EXPORT_MODULE()
|
|||
_bridge = bridge;
|
||||
|
||||
id contextExecutor = RCTGetLatestExecutor();
|
||||
|
||||
[contextExecutor executeBlockOnJavaScriptQueue:^{
|
||||
Ivar ivar = class_getInstanceVariable([contextExecutor class], "_context");
|
||||
id<RCTJavaScriptContext> rctJSContext = object_getIvar(contextExecutor, ivar);
|
||||
JSContextRef ctx = rctJSContext.ctx;
|
||||
RCTJavaScriptContext *rctJSContext = object_getIvar(contextExecutor, ivar);
|
||||
JSGlobalContextRef ctx;
|
||||
if (rctJSContext) {
|
||||
ctx = rctJSContext.ctx;
|
||||
}
|
||||
else {
|
||||
ctx = JSGlobalContextCreate(NULL);
|
||||
object_setIvar(contextExecutor, ivar, [[RCTJavaScriptContext alloc] initWithJSContext:ctx]);
|
||||
}
|
||||
|
||||
[RealmJS initializeContext:ctx];
|
||||
|
||||
RCTLogInfo(@"Realm initialized");
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -6,6 +6,6 @@
|
|||
"start": "node_modules/react-native/packager/packager.sh"
|
||||
},
|
||||
"dependencies": {
|
||||
"react-native": "^0.8.0"
|
||||
"react-native": "0.10.0"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue