customRef<T> function
Ref<T>
customRef<T>(
- ({T Function() get, void Function(T) set}) factory(
- void track(),
- void trigger()
Creates a custom Ref with user-defined getter and setter behavior.
The factory function receives track and trigger functions to manage
dependencies and updates, and should return a record with get and set functions.
T is the type of the value held by the custom Ref.
Returns a new Ref instance with the custom behavior.
Implementation
public.Ref<T> customRef<T>(
({T Function() get, void Function(T) set}) Function(
void Function() track,
void Function() trigger,
) factory,
) {
final dep = impl.Dep();
final (:get, :set) = factory(dep.track, dep.trigger);
return impl.CustomRef(dep, get, set);
}