An abstract use case for running a stream asynchronously via a cubit which
accepts a P
parameter for creating the stream.
The stream is created from the obtained L
R
when watch
is executed successfully. L
is the error returned when stream creation
fails.
The created stream emits either an L
error event or an R
data event.
- Inheritance
-
- Object
- BlocBase<
WatcherState> - Cubit<
WatcherState> - DistinctCubit<
WatcherState> - Watcher
- Mixed in types
-
- BaseUseCase<
P, L, VerboseStream< L, R> >
- BaseUseCase<
Constructors
- Watcher()
-
An abstract use case for running a stream asynchronously via a cubit which
accepts a
P
parameter for creating the stream.
Properties
-
event
↔ Either<
L, R> ? -
The latest value emitted by the watch-created stream which can either
reference the leftEvent or the rightEvent.
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- isClosed → bool
-
Whether the bloc is closed.
no setterinherited
- leftEvent → L?
-
no setter
- leftParams → P?
-
The last params used to execute the use case when it failed.
no setterinherited
- leftValue → L?
-
The error emitted by the watch call that prevented the creation of a
stream.
no setteroverride
-
params
→ Either<
P, P> ? -
The last params used to execute the use case.
no setterinherited
- rightEvent → R?
-
The last data event emitted by the watch-created stream.
no setter
- rightParams → P?
-
The last params used to execute the use case when it succeeded.
no setterinherited
-
rightValue
→ VerboseStream<
L, R> ? -
The VerboseStream returned by a successful watch call.
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- state → WatcherState
-
The current state.
no setterinherited
-
stream
→ Stream<
WatcherState> -
The current stream of states.
no setterinherited
-
value
→ Either<
L, VerboseStream< ?L, R> > -
The latest value emitted by calling watch which can either reference
the leftValue or the rightValue.
no setteroverride
Methods
-
addError(
Object error, [StackTrace? stackTrace]) → void -
Reports an
error
which triggers onError with an optional StackTrace.inherited -
close(
) → Future< void> -
Closes the instance.
This method should be called when the instance is no longer needed.
Once close is called, the instance can no longer be used.
override
-
distinctEmit(
int actionToken, WatcherState stateCallback()) → WatcherState? -
Updates the Cubit's state based on the
stateCallback
.inherited -
emit(
WatcherState state) → void -
Do not use directly. Instead, use distinctEmit.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onCall(
P params) → FutureOr< Either< L, VerboseStream< >L, R> > -
The use case action callback.
inherited
-
onChange(
Change< WatcherState> change) → void -
Called whenever a
change
occurs with the givenchange
. Achange
occurs when a newstate
is emitted. onChange is called before thestate
of thecubit
is updated. onChange is a great spot to add logging/analytics for a specificcubit
.inherited -
onError(
Object error, StackTrace stackTrace) → void -
Called whenever an
error
occurs and notifies BlocObserver.onError.inherited -
requestNewActionToken(
) → int -
Generates a new action token.
inherited
-
reset(
) → Future< void> -
Clears all the data then emits a WatcherInitial.
override
-
setParamsAndValue(
P params, Either< L, VerboseStream< value) → voidL, R> > -
Sets the
params
andvalue
of the use case.inherited -
toString(
) → String -
A string representation of this object.
inherited
-
watch(
{required P params, bool cancelOnError = false}) → Future< Either< L, VerboseStream< ?>L, R> > - Starts creating the stream to watch.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited