import { subscribeKey } from "https://deno.land/x/valtio@v2.1.2/src/vanilla/utils/subscribeKey.ts";
subscribeKey
The subscribeKey utility enables subscription to a primitive subproperty of a given state proxy. Subscriptions created with subscribeKey will only fire when the specified property changes. notifyInSync: same as the parameter to subscribe(); true disables batching of subscriptions.
Examples
import { subscribeKey } from 'valtio/utils'
subscribeKey(state, 'count', (v) => console.log('state.count has changed to', v))
import { subscribeKey } from 'valtio/utils' subscribeKey(state, 'count', (v) => console.log('state.count has changed to', v))
Type Parameters
K extends keyof T