JIntentHelpers<T extends JState> mixin
Provides convenience methods for working with JController inside JIntents.
This mixin simplifies interaction with the controller by automatically
using this intent as the origin for actions such as state updates
or side effect emissions.
Only classes that extend JIntent can use this mixin.
Example usage:
class IncrementIntent extends JIntent<CounterState>
with JMetaData<CounterState>, JIntentHelpers<CounterState> {
@override
String get type => 'counter';
@override
Future<void> onInvoke() async {
update((state) => state.copyWith(value: state.value + 1));
}
}
- Superclass constraints
- JIntent<
T>
- JIntent<
- Mixin applications
Properties
-
controller
→ JController<
T> -
The controller bound by the most recent invocation.
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- isCancelled → bool
-
Whether cancellation was requested for the current execution.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- state → T
-
Provides easy access to the current state managed by the controller.
no setterinherited
Methods
-
cancel(
) → void -
Requests cooperative cancellation of the execution in progress.
inherited
-
emitAndWaitSideEffect<
V> (JEffect< V> effect) → Future<V> - Emits a UI side effect and waits for a result.
-
emitSideEffect(
JEffect effect) → void - Emits a one-time UI side effect from this intent.
-
invoke(
JController< T> controller) → Future<void> -
Wires the controller before executing the logic. Not overridable;
override onInvoke instead. An instance can be reused after completion,
but overlapping invocations fail with StateError before rebinding it.
Invoking against a disposed controller also fails with StateError.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onInvoke(
) → Future< void> -
Contains the core logic of the intent.
inherited
-
run(
JController< T> controller) → Future<void> -
Executes the intent. Not overridable; override onInvoke instead.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
update(
T reducer(T state)) → void -
Updates the controller's state using the provided
reducerfunction.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited