Single<T>.fromCallable constructor
Creates a Single that, when listening to it, calls a function you specify and then emits the value returned from that function.
If result from invoking callable
function:
- Is a Future: when the future completes, this Single will fire one event, either data or error, and then close with a done-event.
- Is a
T
: this Single emits a single data event and then completes with a done event.
By default, this Single is a single-subscription Stream. However, it's possible to make it reusable.
See Rx.fromCallable and FromCallableStream.
Implementation
factory Single.fromCallable(FutureOr<T> Function() callable,
{bool reusable = false}) =>
Single.safe(Rx.fromCallable<T>(callable, reusable: reusable));