jintent library

Intents, state and effects for Flutter.

This entry point holds the core contracts: JState, JIntent, JController, effects, dispatchers, JObserver and the domain helpers. Optional pieces live in their own entry points:

  • package:jintent/devtools.dart: logging, metrics, correlation, overlay.
  • package:jintent/undo_redo.dart: undo/redo and observable history.
  • package:jintent/navigation.dart: a thin Navigator abstraction.
  • package:jintent/utils.dart: throttler and small helpers.
  • package:jintent/testing.dart: test helpers.
  • package:jintent/widgets.dart: controller builder and selector.

Classes

Either<L, R>
Represents a value of one of two possible types, Left or Right.
EitherConfig
Global configuration for error logging.
IBiMapper<A, B>
Interface defining a bidirectional mapper between types A and B.
IMapper<INPUT, OUTPUT>
Generic interface for mapping objects of type INPUT to OUTPUT.
JController<T extends JState>
Base controller for managing state and side effects in a reactive architecture.
JDefaultIntentDispatcher
Default dispatcher implementation that simply invokes the intent.
JDialogEffect<T>
Alias semántico para diálogos (normalmente devuelven un valor, ej. bool).
JDroppableIntentDispatcher
Dispatcher that drops an intent while another one with the same key is still running for the same controller.
JEffect<T>
Base class representing a one-time side effect with an optional result.
JEffectListener<T extends JState>
Listens to side effects emitted by the JController and handles them using the provided JSideEffectHandler. This widget is useful for reacting to one-time UI events such as navigation, dialogs, or snackbars. Handler failures complete pending effect results with the original error and are reported through FlutterError.reportError. Changing controllers replaces the subscription; already running handlers are not cancelled. Removing this widget does not complete or cancel in-flight effect results. Their handler must complete them; callers can set a timeout, and controller disposal fails any results that remain pending. Queued broadcast events may be dropped when the subscription is cancelled before delivery.
JEffectsConfig
Global configuration for JEffect behavior.
JEquatable
A simplified base class that extends Equatable for consistent equality.
JFireAndForgetEffect
Effect that is semánticamente "fire and forget" (no valor útil).
JIntent<T extends JState>
Represents an action or event that can modify application state.
JIntentDispatcher
Interface for dispatching intents.
JMapper<INPUT, OUTPUT>
Base abstract class implementing IMapper to simplify concrete mappers.
JNoParams
A placeholder class representing no parameters for use cases that do not require input parameters.
JObserver
JObserver is a centralized observability utility to track lifecycle events in the JIntent architecture.
JObserverDelegate
Composable observer for the JIntent lifecycle.
JPendingIntentCancellation
Optional lifecycle contract for dispatchers that retain queued intents.
JRestartableIntentDispatcher
Dispatcher that cancels the running intent with the same key when a new one arrives for the same controller, then starts the new intent immediately.
JResultEffect<T>
Effect diseñado para retornar un valor de tipo T.
JSequentialIntentDispatcher
Dispatcher for handling intents sequentially, ensuring that each intent is processed one at a time in the order they are received. Pending tasks can be cancelled per controller without interrupting the running task or changing the order of tasks belonging to other controllers.
JSideEffectHandler<T extends JState>
Base class for handling side effects in a JController. Enhanced to support:
JState
An immutable base class representing the state in an application.
JSyncUseCase<INPUT, OUTPUT>
Base interface for synchronous use cases.
JUseCase<INPUT, OUTPUT>
Base interface for all asynchronous use cases.
JUseCaseVoid<INPUT>
Interface for asynchronous use cases that do not return a value or an Either.
Left<L, R>
Represents a failure or error case.
LoggingDispatcher
Dispatcher decorator that logs intent dispatching lifecycle events.
Represents a success case.

Enums

UnhandledEffectStrategy
Strategy for handling unhandled effects.

Mixins

JCategorizableEffect
Marker for effects that can expose a UI category (analytics/devtools).
JIntentHelpers<T extends JState>
Provides convenience methods for working with JController inside JIntents.
JMetaData<T extends JState>
Provides optional metadata for JIntents to enhance observability and logging.

Extensions

EitherExtensions on Either<L, R>
Useful extensions for working with Either.
MapWithExtension on List<T>
Extension on List providing a convenient method to map elements with a JMapper.

Typedefs

EffectHandler<E extends JEffect, S extends JState> = Future<void> Function(E effect, JController<S> controller, BuildContext context)
Handler for a specific effect E with state S. Returns a Future that completes when the UI has finished processing the effect. Note: DO NOT retain BuildContext after a prolonged await.
ErrorLogger = void Function(Object error)
Function signature for a global error logger.
JIntentKey = Object Function(JIntent<JState> intent)
Computes the group an intent belongs to for concurrency decisions.
UseCaseInputValidator<I> = Either<Exception, I> Function(I input)
A function type that validates the input for a use case.