PersistSignal<T> constructor

PersistSignal<T>({
  1. required FutureOr<T> read(),
  2. required FutureOr<void> write(
    1. T value
    ),
  3. T initialValue()?,
  4. bool lazy,
  5. Duration writeDelay,
  6. JoltDebugFn? onDebug,
})

Creates a persistent signal with the given configuration.

Parameters:

  • read: Function to read the value from storage
  • write: Function to write the value to storage
  • initialValue: Optional function that returns the initial value if storage is empty
  • lazy: Whether to load the value lazily (on first access)
  • writeDelay: Delay before writing to storage (for debouncing)
  • onDebug: Optional debug callback for reactive system debugging

Example:

final persistSignal = PersistSignal(
  read: () => storage.read(),
  write: (value) => storage.write(value),
  lazy: false,
);

Implementation

factory PersistSignal({
  required FutureOr<T> Function() read,
  required FutureOr<void> Function(T value) write,
  T Function()? initialValue,
  bool lazy,
  Duration writeDelay,
  JoltDebugFn? onDebug,
}) = PersistSignalImpl;