Skip to content

Commit

Permalink
fix(ios): add ResponseSenderBlock type support for component parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
wwwcg committed May 14, 2024
1 parent 1d48a6a commit 672fb57
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions framework/ios/base/modules/HippyModuleMethod.mm
Original file line number Diff line number Diff line change
Expand Up @@ -293,14 +293,26 @@ - (void)processMethodSignature {
}
}
} else if ([typeName isEqualToString:@"HippyResponseSenderBlock"]) {
HIPPY_ARG_BLOCK(if (HIPPY_DEBUG && json && ![json isKindOfClass:[NSNumber class]]) {
HippyLogArgumentError(weakSelf, index, json, "should be a function");
return NO;
}
__weak HippyBridge *weakBridge = bridge;
Hippy_BLOCK_ARGUMENT(^(NSArray *args) {
enqueueBlockCallback(weakBridge, weakSelf, json, args);
});)
HIPPY_ARG_BLOCK(
if (!json) {
HippyLogArgumentError(weakSelf, index, json, "should be a response sender function");
return NO;
}
id blockArg = nil;
if (![json isKindOfClass:[NSNumber class]]) {
// In Hippy3.0, Dom Nodes call function by method name directly,
// so it is not a Number anymore.
// See NativeRenderManager::CallFunction() for more.
// TODO: add more type check for safe
blockArg = json;
} else {
__weak HippyBridge *weakBridge = bridge;
blockArg = ^(NSArray *args){
enqueueBlockCallback(weakBridge, weakSelf, json, args);
};
}
Hippy_BLOCK_ARGUMENT(blockArg);
)
} else if ([typeName isEqualToString:@"HippyResponseErrorBlock"]) {
HIPPY_ARG_BLOCK(if (HIPPY_DEBUG && json && ![json isKindOfClass:[NSNumber class]]) {
HippyLogArgumentError(weakSelf, index, json, "should be a function");
Expand All @@ -325,6 +337,7 @@ - (void)processMethodSignature {
// In Hippy3.0, Dom Nodes call function by method name directly,
// so it is not a Number anymore.
// See NativeRenderManager::CallFunction() for more.
// TODO: add more type check for safe
blockArg = json;
} else {
__weak HippyBridge *weakBridge = bridge;
Expand Down

0 comments on commit 672fb57

Please sign in to comment.