Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/valtio/src/vanilla/utils/subscribeKey.ts>subscribeKey

💊 Valtio makes proxy-state simple for React and Vanilla
Go to Latest
function subscribeKey
import { subscribeKey } from "https://deno.land/x/valtio@v2.0.0-beta.5/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))

Type Parameters

T extends object
K extends keyof T

Parameters

proxyObject: T
key: K
callback: (value: T[K]) => void
optional
notifyInSync: boolean