PersistSignal<T> constructor
PersistSignal<T> ({
- T initialValue()?,
- required FutureOr<
T> read(), - required FutureOr<
void> write(- T value
- bool lazy = false,
- Duration writeDelay = Duration.zero,
- JoltDebugFn? onDebug,
Creates a persistent signal with the given configuration.
Parameters:
initialValue: Optional initial value if storage is emptyread: Function to read the value from storagewrite: Function to write the value to storagelazy: 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();
}
}