PersistSignal<T> constructor

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

Creates a persistent signal with the given configuration.

Parameters:

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

Implementation

PersistSignal(
    {T Function()? initialValue,
    required this.read,
    required this.write,
    bool lazy = false,
    this.writeDelay = Duration.zero,
    super.onDebug})
    : super(initialValue != null ? initialValue() : null) {
  if (!lazy) {
    _load();
  }
}