tonApiPaged<S> static method
Future<void>
tonApiPaged<S>(
- int limit,
- Future<
NetResponse< request(S> >- int offset
- NetMapperSuccess mapperSuccess,
- int dataLength(
- S
- Future<
void> onNewData(- ApiResult<
S> newData
- ApiResult<
Implementation
static Future<void> tonApiPaged<S>(
int limit,
Future<NetResponse<S>> Function(int offset) request,
NetMapperSuccess mapperSuccess,
int Function(S) dataLength,
Future<void> Function(ApiResult<S> newData) onNewData) async {
int offset = 0;
do {
final data = await Net.tonApi(() {
var response = request(offset);
return response;
}, mapperSuccess);
var dataSize = 0;
if (data is ApiResultSuccess<S>) {
await onNewData(data);
dataSize = dataLength(data.data);
} else {
await onNewData(data);
return;
}
if (dataSize > 0) {
if(dataSize < limit){
return;
}
offset += dataSize;
} else {
offset = 0;
}
} while (offset > 0);
}