batch_await
- Dominant language
- Objective-C
- Stars
- 4k
- Forks
- 519
- PR merge metrics
- No merged PRs in 30d
Description

在NSArray *co_batch_await(NSArray * awaitableList)函数中为什么会将错误替换进result?
我的场景是使用batch_await调用好几个接口,然后拿到结果刷新页面,但是如果其中一个接口调用失败我将调用reject
NSError *err = [NSError errorWithDomain:@"data error" code:-1 userInfo:nil];
[promise reject:err];
这样,而调用batch_await之后,由于
NSError *error = co_getError();
if (error) {
[result replaceObjectAtIndex:i withObject:error];
}
前面数组中得到的结果也是有error,我在结果取值result[1]的时候并没有得到想要的结果,而是error,这样再走下面的逻辑程序就会有问题,为什么不能将错误放入co_getError中,
想await中那样,最后取得错误另外处理,否则每个result[1], result[2],我都需要判断返回的结果是否有错,再走正常逻辑
NSArray *recommentArray = result[1];
if (![recommentArray isKindOfClass:[NSError class]]) {
goodsObj.recommendArray = recommentArray;
}
NSMutableArray *goodsColorInfo = result[2];
if (![goodsColorInfo isKindOfClass:[NSError class]]) {
[self getHuiMaiColorAndStyleInfo:goodsColorInfo];
}
这样比较繁琐
Contributor guide
Research direction
Start by locating the NSArray *co_batch_await(NSArray *awaitableList) implementation and trace how co_getError() is handled after each awaited item. Reproduce the reported case with one rejected promise and several successful results. Done means the chosen error behavior is agreed, implemented consistently, and covered by a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- objective-c
- Domain
- api
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100