writable<T> method
Creates a writable computed hook that can be both read and written.
When set, the setter function is called to update the underlying dependencies.
Parameters:
getter: Function that computes the current valuesetter: Function that handles value updatesonDebug: Optional debug callback for reactive system debugging
Returns: A WritableComputed with custom read/write behavior
Example:
setup(context, props) {
final firstName = useSignal('John');
final lastName = useSignal('Doe');
final fullName = useComputed.writable(
() => '${firstName.value} ${lastName.value}',
(value) {
final parts = value.split(' ');
firstName.value = parts[0];
lastName.value = parts[1];
},
);
return () => Text(fullName.value);
}
Implementation
Computed<T> writable<T>(T Function() getter, void Function(T) setter,
{JoltDebugFn? onDebug}) {
return useAutoDispose(
() => WritableComputed(getter, setter, onDebug: onDebug));
}