RQCommonViewModel.m 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. //
  2. // RQCommonViewModel.m
  3. // RQCommon
  4. //
  5. // Created by 张嵘 on 2018/11/27.
  6. // Copyright © 2018 张嵘. All rights reserved.
  7. //
  8. #import "RQCommonViewModel.h"
  9. @implementation RQCommonViewModel
  10. - (void)initialize{
  11. [super initialize];
  12. @weakify(self);
  13. /// 选中cell的命令
  14. /// UI Test
  15. self.didSelectCommand = [[RACCommand alloc] initWithSignalBlock:^RACSignal *(NSIndexPath *indexPath) {
  16. @strongify(self);
  17. RQCommonGroupViewModel *groupViewModel = self.dataSource[indexPath.section] ;
  18. RQCommonItemViewModel *itemViewModel = groupViewModel.itemViewModels[indexPath.row];
  19. if (itemViewModel.operation) {
  20. /// 有操作执行操作
  21. itemViewModel.operation();
  22. }else if(itemViewModel.destViewModelClass){
  23. /// 没有操作就跳转VC
  24. Class viewModelClass = itemViewModel.destViewModelClass;
  25. RQBaseViewModel *viewModel = [[viewModelClass alloc] initWithServices:self.services params:@{RQViewModelTitleKey:itemViewModel.title}];
  26. [self.services pushViewModel:viewModel animated:YES];
  27. }
  28. return [RACSignal empty];
  29. }];
  30. }
  31. @end