Home weex - wxbridgecontext
Post
Cancel

weex - wxbridgecontext

topInstance

1
@property (nonatomic, weak, readonly) WXSDKInstance *topInstance;

registerModules

1
2
3
4
5
6
7
8
9
- (void)registerModules:(NSDictionary *)modules
{
    WXAssertBridgeThread();
    
    if(!modules) return;
    
    [self callJSMethod:@"registerModules" args:@[modules]];
    [WXEaglePluginManager registerModules:modules];
}

callJSMethod

1
2
3
4
5
6
7
8
9
- (void)callJSMethod:(NSString *)method args:(NSArray *)args
{
    if (self.frameworkLoadFinished) {
        [self.jsBridge callJSMethod:method args:args];
    }
    else {
        [_methodQueue addObject:@{@"method":method, @"args":args}];
    }
}

jsBridge

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
- (id<WXBridgeProtocol>)jsBridge
{
    WXAssertBridgeThread();
    _debugJS = [WXDebugTool isDevToolDebug];
    
    Class bridgeClass = _debugJS ? NSClassFromString(@"WXDebugger") : [WXJSCoreBridge class];
    
    if (_jsBridge && [_jsBridge isKindOfClass:bridgeClass]) {
        return _jsBridge;
    }
    
    if (_jsBridge) {
        [_methodQueue removeAllObjects];
        _frameworkLoadFinished = NO;
    }
    
    // WXDebugger is a singleton actually and should not call its init twice.
    _jsBridge = _debugJS ? [NSClassFromString(@"WXDebugger") alloc] : [[WXJSCoreBridge alloc] init];
    
    [self registerGlobalFunctions];
    
    return _jsBridge;
}
This post is licensed under CC BY 4.0 by the author.