RQCollectionViewModel.h 2.1 KB

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