From dacdda47c2fd5cb64a1ccf861b842f02524a0188 Mon Sep 17 00:00:00 2001 From: Cherry7 <79909910+CCherry07@users.noreply.github.com> Date: Thu, 23 Jan 2025 21:27:40 +0800 Subject: [PATCH] Update README.md --- README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/README.md b/README.md index 7e5ae14..7654542 100644 --- a/README.md +++ b/README.md @@ -47,3 +47,24 @@ state.count++; state.$nested.value.deep = 'new value'; state.$array.value.push(4); ``` +### watch +```ts +import { deepSignal, watch } from 'alien-deepsignals'; +const state = deepSignal({ + count: 0, + name: 'John', + nested: { + deep: 'value', + }, + array: [1, 2, 3], +}); + +watch(state,(value)=>{ + console.log(value); +},{ + deep: true, + immediate: true, + // once +}) +``` +