JController<T extends JState> class abstract

Base controller for managing state and side effects in a reactive architecture.

Extends StateNotifier<T> to provide controlled state updates and exposes a sideEffects stream for one-time UI events.

Use intent to dispatch intents which encapsulate business logic, update to safely mutate the state using reducers, and emitSideEffect or emitAndWaitSideEffect for UI events like dialogs or navigation.

Implements lifecycle hook onInit for initialization logic.

Tracks state changes and side effects via JObserver for debugging and tooling.

Inheritance
Implementers

Constructors

JController(T initialState, {JIntentDispatcher? dispatcher, int effectBufferSize = 0})
Creates a new JController with the given initial state.

Properties

currentState → T
Returns the current state of type T.
no setter
debugState → T
A development-only way to access state outside of StateNotifier.
no setterinherited
hashCode → int
The hash code for this object.
no setterinherited
hasListeners → bool
If a listener has been added using addListener and hasn't been removed yet.
no setterinherited
mounted → bool
Whether dispose was called or not.
no setterinherited
onError ↔ ErrorListener?
A callback for error reporting if one of the listeners added with addListener throws.
getter/setter pairinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
sideEffects → Stream<JEffect>
A broadcast stream of side effects emitted by the controller.
no setter
state ↔ T
The current "state" of this StateNotifier.
getter/setter pairinherited
stream → Stream<T>
A broadcast stream representation of a StateNotifier.
no setterinherited

Methods

addListener(Listener<T> listener, {bool fireImmediately = true}) → RemoveListener
Subscribes to this object.
inherited
dispose() → void
Fails pending awaitable effects and closes the side effects stream. Cancels queued intents if the dispatcher supports JPendingIntentCancellation. Already running handlers and intents are not interrupted. External work must check mounted or use its own cancellation API after asynchronous gaps.
override
emitAndWaitSideEffect<V>(JEffect<V> effect, {Duration? timeout}) → Future<V>
Emits a JEffect and waits for its completion or timeout. Missing listeners and disposal fail with StateError. This does not cancel UI handlers or external operations that have already started.
emitSideEffect(JEffect effect) → void
Emits a one-time JEffect to the UI.
intent(JIntent<T> intent) → Future<void>
Handles a given JIntent to update the state.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onInit() → void
Initialization lifecycle method.
setState(T newState, {JIntent<JState>? origin}) → void
Sets a new state of type T if different from the current state.
toString() → String
A string representation of this object.
inherited
update(T reducer(T state), {JIntent<JState>? origin}) → void
Updates the current state by applying the given reducer function.
updateShouldNotify(T old, T current) → bool
Whether to notify listeners or not when state changes
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited