PersistSignal<T>.sync constructor

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

Creates a synchronous persistent signal.

Parameters:

  • read: Sync function to read from storage
  • write: Function to write to storage
  • lazy: Defer loading until first access (default: false)
  • throttle: Delay before writing (null = no throttling)
  • onDebug: Optional debug callback

Example:

final theme = PersistSignal.sync(
  read: () => prefs.getString('theme') ?? 'light',
  write: (value) => prefs.setString('theme', value),
);

Implementation

factory PersistSignal.sync({
  required T Function() read,
  required FutureOr<void> Function(T value) write,
  bool lazy,
  Duration? throttle,
  JoltDebugFn? onDebug,
}) = SyncPersistSignalImpl<T>;