Skip to content

watch beta ​

Function of @v12-engine/client

ts
export declare function watch<T>(read: () => T, listener: (value: T) => void, options?: {
    immediate?: boolean;
}): () => void;

Follows what a read of the client's state uses, from any code: no Solid in the caller. read is called where it is tracked, so it reads signals (client.ui.selection(), a controller's saves.list()) and may work something out from several; listener is told the value each time it changes, and never as it starts (immediate for that too). Gives back what stops it.

const stop = watch(() = client.ui.selection().length, (count) = draw(count))

It lives in a root of its own, owned by nothing, until what it gives back is called