LoggingMiddleware<T> class

A prebuilt middleware for logging state changes in Fluxivity.

This middleware logs all state changes to the console, including:

  • Value updates (before and after)
  • Errors during computation

It can be used as a debugging tool to track state changes throughout your application.

Example usage:

// Add logging to a reactive value
final counter = Reactive(0, middlewares: [LoggingMiddleware<int>()]);

// Add logging to a computed value
final doubled = Computed([counter], (sources) {
  return sources[0].value * 2;
}, middlewares: [LoggingMiddleware<int>()]);

// Updates will be logged to the console
counter.value = 5;
// Console output:
// Before update: 0 -> 5
// After update: 0 -> 5
// Before update: 0 -> 10 (for the computed value)
// After update: 0 -> 10 (for the computed value)

This middleware always returns true from shouldEmit, so it never interferes with the normal behavior of state updates.

Inheritance

Constructors

LoggingMiddleware()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

afterUpdate(T oldValue, T newValue) → void
Called immediately after a value has been updated.
override
beforeUpdate(T oldValue, T newValue) → void
Called immediately before a value is updated.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onError(Object error, StackTrace stackTrace) → void
Called when an error occurs during computation in a Computed instance.
override
shouldEmit(T oldValue, T newValue) bool
Determines whether a value change should trigger a notification to listeners.
override
toString() String
A string representation of this object.
inherited

Operators

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