PersistSignalImpl<T> constructor
PersistSignalImpl<T> ({
- required FutureOr<
T> read(), - required FutureOr<
void> write(- T value
- T initialValue()?,
- bool lazy = false,
- Duration writeDelay = Duration.zero,
- JoltDebugFn? onDebug,
Creates a persistent signal with the given configuration.
Parameters:
initialValue: Optional function that returns the 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
If lazy is false, the value will be loaded from storage immediately.
If lazy is true, the value will be loaded on first access via value or get.
Implementation
PersistSignalImpl(
{required this.read,
required this.write,
T Function()? initialValue,
bool lazy = false,
this.writeDelay = Duration.zero,
super.onDebug})
: super(initialValue != null ? initialValue() : null) {
if (!lazy) {
unawaited(_load());
}
}