addStatesSource<S> method
StreamSubscription<S> ?
addStatesSource<S>(
- Stream<
S> source, { - void onData(
- S data
- void onDone()?,
- void onError(
- dynamic error
Adds states Stream of S
type as source of states.
Callbacks onData
, onDone
, onError
help to handle source
.
Throws ArgumentError if state of such type was not registered.
Returns StreamSubscription that provide possibility to pause, resume or cancel source
.
Returns null
if this Bloc was disposed.
WARNING!!! This class doesn't respond for cancellation and closing of source
stream. Developer should do
it on his own, if necessary.
Implementation
@protected
StreamSubscription<S>? addStatesSource<S>(Stream<S> source,
{void Function(S data)? onData,
void Function()? onDone,
void Function(dynamic error)? onError}) {
return isDisposed
? null
: (_store[S] as _StateDeliveryController<S>).addSource(source,
onData: onData, onDone: onDone, onError: onError);
}