import { watch } from "https://deno.land/x/valtio@v2.1.1/src/vanilla/utils.ts";
watch
Creates a reactive effect that automatically tracks proxy objects and reevaluates everytime one of the tracked proxy objects updates. It returns a cleanup function to stop the reactive effect from reevaluating.
Callback is invoked immediately to detect the tracked objects.
Callback passed to watch
receives a get
function that "tracks" the
passed proxy object.
Watch callbacks may return an optional cleanup function, which is evaluated
whenever the callback reevaluates or when the cleanup function returned by
watch
is evaluated.
watch
calls inside watch
are also automatically tracked and cleaned up
whenever the parent watch
reevaluates.