map<U> method
Implementation
Future<NEResult<U>> map<U>(FutureOr Function() mapper) {
return then<NEResult<U>>((value) async {
if (value.isSuccess()) {
try {
final next = await mapper();
if (next is NEResult) {
return next as NEResult<U>;
} else {
return NEResult<U>.successWith(next as U);
}
} catch (e, _) {
assert(() {
throw e;
}());
return NEResult<U>(code: -1, msg: e.toString());
}
} else {
return NEResult<U>(
code: value.code,
msg: value.msg,
requestId: value.requestId,
cost: value.cost);
}
});
}