File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,9 @@ This is to describe the high level abstraction of valtio.
2121import { proxy , subscribe } from ' valtio'
2222
2323const s1 = proxy ({})
24- subscribe (s1, () => { console .log (' s1 is changed!' ) })
24+ subscribe (s1, () => {
25+ console .log (' s1 is changed!' )
26+ })
2527s1 .a = 1 // s1 is changed!
2628++ s1 .a // s1 is changed!
2729delete s1 .a // s1 is changed!
@@ -30,11 +32,15 @@ s1.b = 2 // (not changed)
3032s1 .obj = {} // s1 is changed!
3133s1 .obj .c = 3 // s1 is changed!
3234const s2 = s1 .obj
33- subscribe (s2 () => { console .log (' s2 is changed!' ) })
35+ subscribe (s2, () => {
36+ console .log (' s2 is changed!' )
37+ })
3438s1 .obj .d = 4 // s1 is changed! and s2 is changed!
3539s2 .d = 5 // s1 is changed! and s2 is changed!
3640const s3 = proxy ({})
37- subscribe (s3 () => { console .log (' s3 is changed!' ) })
41+ subscribe (s3, () => {
42+ console .log (' s3 is changed!' )
43+ })
3844s1 .o = s3
3945s3 .p = ' hello' // s1 is changed! and s3 is changed!
4046s2 .q = s3
You can’t perform that action at this time.
0 commit comments