Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Commit

Permalink
* [iOS] fix typo error about completion
Browse files Browse the repository at this point in the history
  • Loading branch information
doumafang committed Aug 13, 2018
1 parent c232394 commit a4fabec
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 14 deletions.
2 changes: 1 addition & 1 deletion ios/playground/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ platform :ios, '8.0'

def common
pod 'WeexSDK', :path=>'../../'
pod 'WXDevtool', '0.15.3'
pod 'WXDevtool','0.16.1'
pod 'SDWebImage', '3.7.5'
pod 'SocketRocket', '0.4.2'
pod 'ATSDK-Weex', '0.0.1',:configurations => ['Debug']
Expand Down
3 changes: 1 addition & 2 deletions ios/playground/WeexDemo/Scanner/WXScannerVC.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
#import "UIViewController+WXDemoNaviBar.h"
#import "WXDemoViewController.h"
#import "WXDebugTool.h"

#import <TBWXDevTool/WXDevTool.h>
#import "WXDevTool.h"
#import <AudioToolbox/AudioToolbox.h>

@interface WXScannerVC ()
Expand Down
17 changes: 9 additions & 8 deletions ios/sdk/WeexSDK/Sources/Bridge/WXBridgeContext.m
Original file line number Diff line number Diff line change
Expand Up @@ -797,30 +797,31 @@ - (void)executeJsMethod:(WXCallJSMethod *)method
[self performSelector:@selector(_sendQueueLoop) withObject:nil];
}

- (void)callJSMethod:(NSString *)method args:(NSArray *)args onContext:(id<WXBridgeProtocol>)bridge completion:(void (^)(JSValue * value))complection
- (void)callJSMethod:(NSString *)method args:(NSArray *)args onContext:(id<WXBridgeProtocol>)bridge completion:(void (^)(JSValue * value))completion
{
NSMutableArray *newArg = nil;
if (!bridge) {
bridge = self.jsBridge;
}
if (self.frameworkLoadFinished) {
newArg = [args mutableCopy];
if ([newArg containsObject:complection]) {
[newArg removeObject:complection];
if ([newArg containsObject:completion]) {
[newArg removeObject:completion];
}
WXLogDebug(@"Calling JS... method:%@, args:%@", method, args);
if ([bridge isKindOfClass:[WXJSCoreBridge class]]) {
if (([bridge isKindOfClass:[WXJSCoreBridge class]]) ||
([bridge isKindOfClass:NSClassFromString(@"WXDebugger") ]) ) {
JSValue *value = [bridge callJSMethod:method args:args];
if (complection) {
complection(value);
if (completion) {
completion(value);
}
} else {
[bridge callJSMethod:method args:args];
}
} else {
newArg = [args mutableCopy];
if (complection) {
[newArg addObject:complection];
if (completion) {
[newArg addObject:completion];
}
[_methodQueue addObject:@{@"method":method, @"args":[newArg copy]}];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,14 @@ - (void)updateBindingData:(NSDictionary *)data
__componentId++;
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
[[WXSDKManager bridgeMgr] callComponentHook:self.weexInstance.instanceId componentId:self.attributes[@"@templateId"] type:@"lifecycle" hook:@"create" args:@[self->_virtualComponentId, newData] competion:^(JSValue *value) {
[newData addEntriesFromDictionary:[value toDictionary][@"0"]];
if ([value isKindOfClass:[NSDictionary class]]) {
NSDictionary *valueDict = (NSDictionary *) value;
[newData addEntriesFromDictionary:valueDict[@"0"]];
}
else
{
[newData addEntriesFromDictionary:[value toDictionary][@"0"]];
}
[newData setObject:indexPath forKey:@"indexPath"];
[newData setObject:listRef forKey:@"recycleListComponentRef"];
[[recycleListComponent dataManager] updateVirtualComponentData:self->_virtualComponentId data:newData];
Expand Down
4 changes: 2 additions & 2 deletions ios/sdk/WeexSDK/Sources/Manager/WXBridgeManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ - (void)fireEvent:(NSString *)instanceId ref:(NSString *)ref type:(NSString *)ty
[self callJsMethod:method];
}

- (void)callComponentHook:(NSString*)instanceId componentId:(NSString*)componentId type:(NSString*)type hook:(NSString*)hookPhase args:(NSArray*)args competion:(void (^)(JSValue * value))complection
- (void)callComponentHook:(NSString*)instanceId componentId:(NSString*)componentId type:(NSString*)type hook:(NSString*)hookPhase args:(NSArray*)args competion:(void (^)(JSValue * value))completion
{
WXPerformBlockOnBridgeThread(^{
if (!type || !instanceId || !hookPhase) {
Expand All @@ -365,7 +365,7 @@ - (void)callComponentHook:(NSString*)instanceId componentId:(NSString*)component
NSArray *newArgs = @[componentId, type, hookPhase, args?:@[]];

WXCallJSMethod * method = [[WXCallJSMethod alloc] initWithModuleName:nil methodName:@"componentHook" arguments:newArgs instance:[WXSDKManager instanceForID:instanceId]];
[self.bridgeCtx callJSMethod:@"callJS" args:@[instanceId, @[method.callJSTask]] onContext:nil completion:complection];
[self.bridgeCtx callJSMethod:@"callJS" args:@[instanceId, @[method.callJSTask]] onContext:nil completion:completion];
});
}

Expand Down

0 comments on commit a4fabec

Please sign in to comment.