then<R> method
Future<R>
then<R>(
- FutureOr<
R> onValue(- TetherClientReturn<
TModel> value
- TetherClientReturn<
- Function? onError,
override
Main execution point - when the future is awaited
Implementation
@override
Future<R> then<R>(
FutureOr<R> Function(TetherClientReturn<TModel> value) onValue, {
Function? onError,
}) {
Future<TetherClientReturn<TModel>> operation;
switch (type) {
case SqlOperationType.select:
operation = _executeSelect();
break;
case SqlOperationType.insert:
operation = _executeInsert().then((model) => model);
break;
case SqlOperationType.update:
operation = _executeUpdate().then((model) => model);
break;
case SqlOperationType.delete:
operation = _executeDelete().then(
(_) => TetherClientReturn<TModel>(data: [], count: 0, error: null),
);
break;
case SqlOperationType.upsert:
operation = _executeUpsert().then((model) => model);
break;
default:
throw UnsupportedError('Unsupported operation type: $type');
}
return operation.then(onValue, onError: onError);
}