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 updatesdebug: Optional debug options
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
@defineHook
Computed<T> writable<T>(T Function() getter, void Function(T) setter,
{JoltDebugOption? debug}) {
return useAutoDispose(() => WritableComputed(getter, setter, debug: debug));
}