关于v1.5.1 BHModuleManager分发module事件
Closed this issue · 10 comments
cleexiang commented
环境: pod 'BeeHive', '1.5.1'
BHModuleManager 分发module事件的时候,逻辑有明显错误,导致module不能正确调用modInit方法.
- (void)addModuleFromObject:(id)object {
NSMutableDictionary *moduleInfo = [NSMutableDictionary dictionary];
......
[self.BHModules addObject:moduleInfo]; //这里的BHModules数组存放的都是NSMutableDictionary
}
但是在分发事件的地方:
[self.BHModules enumerateObjectsUsingBlock:^(id<BHModuleProtocol> moduleInstance, NSUInteger idx, BOOL * _Nonnull stop) {
//这里的moduleInstance 是 NSMutableDictionary 而不是 协议BHModuleProtocol的实例
if (sself) {
if ([moduleInstance respondsToSelector:@selector(modInit:)]) {
[moduleInstance modInit:[BHContext shareInstance]];
}
}
};
MemoryReload commented
@cleexiang 你代码是不是太旧了,我都没有搜到你说的这个方法,现在只有
- (void)addModuleFromObject:(id)object
shouldTriggerInitEvent:(BOOL)shouldTriggerInitEvent
这个方法了,好像。
cleexiang commented
@MemoryReload 我用的1.5.1,我看最新版本就是这个啊,你是哪个版本?
MemoryReload commented
@cleexiang On commit 933eaff
, and online review https://github.com/alibaba/BeeHive/blob/master/BeeHive/BHModuleManager.m
I can not find the code you've shown above.
cleexiang commented
@MemoryReload I see! I used pod 'BeeHive', not branch master
MemoryReload commented
@cleexiang Good luck, dude!
davidfuzju commented
@cleexiang 按理说下游依赖不应该直接依赖 master 分支上的代码吧
cleexiang commented
@SuperMarioBean 对啊,没有依赖master
dev-xdyang commented
@MemoryReload 我拉了分支,看了下。在git 1.5.1的tag下代码确实有问题,还是 @cleexiang 列出的函数,但mater分支的代码已经修改,希望能尽快发个新的版本修复这个问题
SoXeon commented
已更新master,pod 1.6.0
cleexiang commented
cool