Skip to content

Commit 1a612ff

Browse files
author
乔同X
authored
Update README.md
1 parent 62efbe9 commit 1a612ff

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

README.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,71 @@
88

99
pod 'JSLoadMoreService', '~> 1.1.0'
1010

11+
# 使用
12+
优雅的建一个viewmodel类,
13+
然后下面就是怎样调用分类的方法:
14+
```- (RACSignal *)siganlForJokeDataIsReload:(BOOL)isReload{
15+
16+
RACReplaySubject *subject = [RACReplaySubject subject];
17+
[[self js_singalForSingleRequestWithURL:Test_Page_URL
18+
para:nil
19+
keyOfArray:@"pdlist"
20+
classNameOfModelArray:@"JSGoodListModel"
21+
isReload:isReload] subscribeNext:^(id _Nullable x) {
22+
/**
23+
* x : 分类方法(js_singalForSingleRequestWithURL:...)里 sendNext 传过来的数组
24+
* 你可以对每次传过来的数组的元素"再加工",知道达到你的要求后 再 sendNext
25+
*/
26+
//...
27+
[subject sendNext:x];
28+
} error:^(NSError * _Nullable error) {
29+
[subject sendError:error];
30+
} completed:^{
31+
/**
32+
* 走到这里为,每次分页请求所有逻辑处理完毕
33+
*/
34+
[subject sendCompleted];
35+
}];
36+
37+
return subject;
38+
}
39+
```
40+
在你的cellForRowAtIndexPath:代理里选择调用回调
41+
```**
42+
* 根据当期index计算是否回调preloadblock
43+
*/
44+
[self preloadDataWithCurrentIndex:indexPath.row];
45+
```
46+
47+
优雅的配置tableview的上拉刷新和预加载
48+
49+
```- (JSListTableView *)listTableView{
50+
51+
if (!_listTableView) {
52+
_listTableView = [[JSListTableView alloc] initWithFrame:self.view.bounds
53+
style:UITableViewStyleGrouped];
54+
[self.view addSubview:_listTableView];
55+
56+
kWeakSelf(self)
57+
/**
58+
* 刷新
59+
*/
60+
[_listTableView headerReloadBlock:^{
61+
kStrongSelf(self)
62+
[self requestGoodListIsReload:YES];
63+
}];
64+
/**
65+
* 预加载
66+
*/
67+
_listTableView.js_preloadBlock = ^{
68+
kStrongSelf(self)
69+
[self requestGoodListIsReload:NO];
70+
};
71+
}
72+
return _listTableView;
73+
}
74+
```
75+
76+
详细的实现步骤请访问[我的博客](http://qiaotongxin.cc/2017/08/06/20170807/)
77+
78+
如果用起来能让你愉悦,别忘记给个star,👍一下~

0 commit comments

Comments
 (0)