PersistSignal<T>.async constructor
PersistSignal<T>.async ({
- required Future<
T> read(), - required FutureOr<
void> write(- T value
- T initialValue()?,
- bool lazy,
- Duration? throttle,
- JoltDebugOption? debug,
Creates an asynchronous persistent signal.
Parameters:
read: Async function to read from storagewrite: Function to write to storageinitialValue: Optional temporary value during loading (null if omitted)lazy: Defer loading until first access (default: false)throttle: Delay before writing (null = no throttling)debug: Optional debug options
Example:
final counter = PersistSignal.async(
read: () async => await prefs.getInt('counter') ?? 0,
write: (value) => prefs.setInt('counter', value),
initialValue: () => 0, // Show while loading
);
Implementation
factory PersistSignal.async({
required Future<T> Function() read,
required FutureOr<void> Function(T value) write,
T Function()? initialValue,
bool lazy,
Duration? throttle,
JoltDebugOption? debug,
}) = AsyncPersistSignalImpl<T>;