ControllableSubscriptions<T extends XState> mixin
A mixin for XControllers that helps to control stream subscriptions.
The subscriptions that you will subscribe to will be automatically cancelled when the controller is disposed.
Attach it to your controller:
class MyController extends XController<MyState> with ControllableSubscriptions {
...
}
Now use it in, for example, onProvided
method:
@override
void onProvided() {
super.onProvided();
subscribeTo(stream.listen.onStream);
subscribeToAll([
stream1.listen.onStream1,
stream2.listen.onStream2,
]);
}
}
- Superclass Constraints
- XController<
T>
- XController<
Properties
- effectStream → Stream
-
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- isDisposed → bool
-
Whether the controller was disposed (e.g. unmounted from the screen).
no setterinherited
- isProvided → bool
-
Whether the controller has been provided.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- state → T
-
The current state of this controller.
no setterinherited
-
stateStream
→ Stream<
T> -
no setterinherited
Methods
-
createInitialState(
) → T -
Creates the initial state when state is references for the first time.
inherited
-
dispose(
) → void -
Disposes the object.
override
-
emit(
T state) → void -
Emits a new state of this controller.
inherited
-
fireEffect(
dynamic effect) → void -
Fires a new side effect via the effectStream.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onProvided(
) → void -
Called after the controller was provided to the tree for the first time.
inherited
-
subscribeTo(
StreamSubscription subscription) → void - Subscribes to the given subscription to cancel it on dispose.
-
subscribeToAll(
Iterable< StreamSubscription> subscriptions) → void - Subscribes to the list of given subscriptions to cancel them on dispose.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited