SyncPersistSignalImpl<T> constructor
SyncPersistSignalImpl<T> ({
- required T read(),
- required FutureOr<
void> write(- T value
- bool lazy = false,
- Duration? throttle,
- JoltDebugFn? onDebug,
Creates a synchronous persistent signal.
Parameters:
read: Synchronous function to read from storagewrite: Function to write to storagelazy: 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
SyncPersistSignalImpl({
required this.read,
required this.write,
bool lazy = false,
this.throttle,
super.onDebug,
}) : super(null) {
if (!lazy) {
_loadSync();
}
}