dispatch method

  1. @override
Future<BaseModel<T>> dispatch()
override

约定: dispatch().then 代表 网络&业务逻辑 都是成功

Implementation

@override
Future<BaseModel<T>> dispatch() {
  _updatePageParam();
  return super.dispatch().then((value) {
    if (value.list.length < pageSize) {
      loadNoData();
    } else {
      if (isOnLoad) {
        loadComplete();
      } else {
        refreshCompleted();
      }
    }
    return value;
  }, onError: (e) {
    if (isOnLoad) {
      loadFailed();
      page--;
    } else {
      refreshFailed();
    }
    throw e;
  });
}