resolvable method
Returns a Resolvable that provides access to the completer's result.
If the completer has already been resolved synchronously, this will return a Sync with the value. Otherwise, it returns an Async containing the completer's future.
Implementation
@pragma('vm:prefer-inline')
Resolvable<T> resolvable() {
// Dispatch inline. Going through `Resolvable.new(() {...})` would invoke
// the caller's closure to peek at the value, then allocate a second
// closure for the chosen `Sync()`/`Async()`. By branching here we save
// one closure allocation per call.
final v = _value;
if (v is Some<FutureOr<T>>) {
final inner = v.value;
if (inner is Future<T>) return Async<T>(() => inner);
return Sync.okValue(inner);
}
return Async<T>(() => _completer.future);
}