LevitReactiveMiddleware class abstract
Base class for intercepting reactive system events.
Implement this class to create cross-cutting tools like loggers, dev-tools, or state synchronization plugins.
You can intercept:
- State changes (onSet, onBatch)
- Lifecycle events (onInit, onDispose)
- Graph updates (onGraphChange)
- Listener activity (startedListening, stoppedListening)
- Errors (onReactiveError)
Constructors
- LevitReactiveMiddleware()
-
Base constructor.
const
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- onBatch → LxOnBatch?
-
Intercepts batch operations.
no setter
- onDispose → LxOnDispose?
-
Intercepts disposal.
no setter
-
onGraphChange
→ void Function(LxReactive computed, List<
LxReactive> dependencies)? -
Observes changes to the dependency graph of a computed value.
no setter
- onInit → void Function(LxReactive reactive)?
-
Observes initialization of new reactive objects.
no setter
- onReactiveError → void Function(Object error, StackTrace? stack, LxReactive? context)?
-
Observes errors caught during notification.
no setter
- onSet → LxOnSet?
-
Intercepts value mutations.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- startedListening → void Function(LxReactive reactive, LxListenerContext? context)?
-
Observes when a new listener is added.
no setter
- stoppedListening → void Function(LxReactive reactive, LxListenerContext? context)?
-
Observes when a listener is removed.
no setter
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- bypassMiddleware → bool
-
Returns
trueif middlewares are currently being bypassed.no setter - hasBatchMiddlewares → bool
-
Whether any active middleware intercepts batch operations.
no setter
- hasDisposeMiddlewares → bool
-
Whether any active middleware observes disposal.
no setter
- hasErrorMiddlewares → bool
-
Whether any active middleware intercepts errors.
no setter
- hasGraphChangeMiddlewares → bool
-
Whether any active middleware tracks dependency graph changes.
no setter
- hasInitMiddlewares → bool
-
Whether any active middleware observes initialization.
no setter
- hasListenerMiddlewares → bool
-
Whether any active middleware tracks listener attachment/detachment.
no setter
- hasSetMiddlewares → bool
-
Whether any active middleware intercepts setting values.
no setter
Static Methods
-
add(
LevitReactiveMiddleware middleware, {Object? token}) → LevitReactiveMiddleware - Adds a middleware to the global registry.
-
clear(
) → void - Clears all currently registered middlewares.
-
contains(
LevitReactiveMiddleware middleware) → bool -
Returns
trueif the middleware is currently registered. -
containsToken(
Object token) → bool -
Returns
trueiftokenis currently registered. -
remove(
LevitReactiveMiddleware middleware) → bool - Removes a middleware from the global registry.
-
removeByToken(
Object token) → bool -
Removes a middleware by
token. -
runWithoutMiddleware(
void action()) → void -
Bypasses all middlewares for the duration of
action.