RQTableViewModel.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. //
  2. // RQTableViewModel.h
  3. // RQCommon
  4. //
  5. // Created by 张嵘 on 2018/11/23.
  6. // Copyright © 2018 张嵘. All rights reserved.
  7. //
  8. #import "RQBaseViewModel.h"
  9. @interface RQTableViewModel : RQBaseViewModel
  10. /// The data source of table view. 这里不能用NSMutableArray,因为NSMutableArray不支持KVO,不能被RACObserve
  11. @property (nonatomic, readwrite, copy) NSArray *dataSource;
  12. /// tableView‘s style defalut is UITableViewStylePlain , 只适合 UITableView 有效
  13. @property (nonatomic, readwrite, assign) UITableViewStyle style;
  14. /// 需要支持下来刷新 defalut is NO
  15. @property (nonatomic, readwrite, assign) BOOL shouldPullDownToRefresh;
  16. /// 需要支持上拉加载 defalut is NO
  17. @property (nonatomic, readwrite, assign) BOOL shouldPullUpToLoadMore;
  18. /// 是否数据是多段 (It's effect tableView's dataSource 'numberOfSectionsInTableView:') defalut is NO
  19. @property (nonatomic, readwrite, assign) BOOL shouldMultiSections;
  20. /// 是否在上拉加载后的数据,dataSource.count < pageSize 提示没有更多的数据.default is NO 默认做法是数据不够时,隐藏mj_footer
  21. @property (nonatomic, readwrite, assign) BOOL shouldEndRefreshingWithNoMoreData;
  22. /// 当前页 defalut is 1
  23. @property (nonatomic, readwrite, assign) NSUInteger page;
  24. /// 每一页的数据 defalut is 20
  25. @property (nonatomic, readwrite, assign) NSUInteger perPage;
  26. /// 数据总数 defalut is 0
  27. @property (nonatomic, readwrite, assign) NSUInteger dataTotalNum;
  28. /// 选中命令 eg: didSelectRowAtIndexPath:
  29. @property (nonatomic, readwrite, strong) RACCommand *didSelectCommand;
  30. /// 请求服务器数据的命令
  31. @property (nonatomic, readonly, strong) RACCommand *requestRemoteDataCommand;
  32. /// 占位empty类型
  33. //@property (nonatomic, readwrite, assign) SBDefaultEmptyBackgroundType emptyType;
  34. @property (nonatomic, readwrite, strong) UIImage *emptyImage;
  35. @property (nonatomic, readwrite, copy) NSString *emptyTex;
  36. /// 网络不可用 default is NO
  37. @property (nonatomic, readwrite, assign) BOOL disableNetwork;
  38. /** fetch the local data */
  39. - (id)fetchLocalData;
  40. /// 请求错误信息过滤
  41. - (BOOL (^)(NSError *error))requestRemoteDataErrorsFilter;
  42. /// 当前页之前的所有数据
  43. - (NSUInteger)offsetForPage:(NSUInteger)page;
  44. /** request remote data or local data, sub class can override it
  45. * page - 请求第几页的数据
  46. */
  47. - (RACSignal *)requestRemoteDataSignalWithPage:(NSUInteger)page;
  48. @end