一个视图渲染器.
1. indexPathForObject 实现有问题
```
- (nullable NSIndexPath *)indexPathForObject:(nonnull NSObject *)object {
ZHComment * comment = [self getCommentFromObject:object];
if (!comment) {
return nil;
}
CKTransactionalComponentDataSourceState *currentState = [self.ckDatasource valueForKey:@"_currentState"];
```
2. 使用 datasource 来查找 model,会让数据更加同步
```
return [self.ckDatasource modelForItemAtIndexPath:indexPath];
```
3. 使用 ck 生成 removeAll 的 changeSet (可能有未提交的 changeset,导致 index 错误)
事件处理方法/工作流程:
1. 在事件的 handler 中一般可以得到该 cell 绑定的 model,如果没有事先存储,此时可以使用 self.ckDataSource modelAtIndexPath
2. 如果需要 「更新/删除」 此 cell ,则要在 viewModel 里面计算出它所在的位置转换成 changeSet 提交给 CK.
需要修改的实现:
- 移除 viewModel 对 ckDataSource 的引用.
- 去掉indexPathForObject 的实现
- 对于 section 数量变更时的刷新操作
1. 慢速网络
2. 增加每次返回的数据集,比如 x5, x10
3. 针对性的模拟数据测试:比如第一屏只返回精选评论
同步和异步提交 changeSet 会怎么样,不会有大问题,只不过同步提交时,如果有未完成的异步 changeset 会造成在主线程中进行布局计算,此时有可能会造成 UI 卡顿.