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