XFLegoVIPER
XFLegoVIPER copied to clipboard
MVVM模块下,RACObserve(self.dataDriver, expressData)奔溃
在mVVM模块下,bindViewData方法中,仅打开默认的绑定代码块RACObserve:
XF_Define_Weak
[RACObserve(self.dataDriver, expressData) subscribeNext:^(NSString *imgUrl) {
XF_Define_Strong
// 如果有显示数据加载完成
}];
奔溃位置:
#15 0x00000001065d1b0c in -[RACKVOTrampoline initWithTarget:observer:keyPath:options:block:] at /Users/jhmac/hsg/SupervisionSel/Pods/ReactiveCocoa/ReactiveCocoa/RACKVOTrampoline.m:50
ReactiveCocoa版本是2.5.2吗
项目依赖:
pod 'ReactiveCocoa', '~> 2.5'
官网好像没有2.5.2版本
刚尝试了:
pod 'ReactiveCocoa', :git => 'https://github.com/zhao0/ReactiveCocoa.git', :tag => '2.5.2'
问题还存在。
我打开例子工程的XFAboutViewController里的这段注释,运行是正常的,我提交了,你可以拉下来运行看看
对比了差异: 我是用router注册方式,然后执行宏push: 这样就会导致issues描述的崩溃,想问下,mvvm模块不支持注册吗?
#1. 注册
// 配置乐高框架 // 使有默认配置
[[XFLegoConfig defaultConfig]
addComponentHanderPlug:[LEMVVMModuleHandler class]]; // 添加扩展MVVM模块组件处理器
[XFURLRoute initURLGroup:@[
@"rac://Login", // mvvm组件
]];
#2. push
XF_PUSH_Component_Fast(@"rac://Login")
项目XFAboutViewController的处理方式:
XFAboutViewController *aboutVC = [[XFAboutViewController alloc] init];
// [LEMVVMConnector makeComponentFromUInterface:aboutVC forName:@"about"];
[LEMVVMConnector makeComponentFromUInterface:aboutVC forName:@"about" intentData:@{@"id":@(123)}];
UINavigationController *nav = [[XFNavigationController alloc] initWithRootViewController:aboutVC];
[self.realUInterface presentViewController:nav animated:YES completion:nil];
例子中的用法是旧项目里从ViewController --跳转到--> MVVM组件,起到桥接旧项目的目的,你使用URL注册并执行宏push也是可以的,例子改了下,你下下来看看,没有问题的
另外,MVVM组件不是必需继承LEViewController,可以通过实现协议的方式@interface XFAboutViewController : UIViewController <LEMVVMIntent>,内部会通过动态绑定实现组件化的
我fork项目,然后使用mvvm模块创建了一个模块:XFRAC,经过下面步骤,还是奔溃。
- 注册
@"xf://search/XFRAC",
- 跳转
XF_Present_URLComponent_Fast(@"xf://search/XFRAC?nav=UI")
方便试一下吗?fork
test监听调用的XFRAC模块:

将所类的前缀XFRAC 改为XFRac,另外XF_Present_URLComponent_Fast(@"xf://search/XFRAC?nav=UI")改为XF_Present_URLComponent_Fast(@"xf://search/rac?nav=UI")