@@ -6,7 +6,7 @@ A tiny state manager for **React**
66and vanilla JS. (other frameworks in future)
77point changes
88
9- - ** Lightweight.** Less than 435 bytes (minified and gzipped). Zero dependencies.
9+ - ** Lightweight.** Core less than 135 bytes (minified and gzipped). Zero dependencies.
1010- ** Easy but strong.** Simple working principe without magic, but with all features from big state managers.
1111- ** Deep observable and fast.** You can subscribe and follow pinpoint changes without thinking about multiple re-renders.
1212- ** Strong plugin system.** With plugins, you can enhance your store. Logging, undoing changes, connecting ** Redux-devtools** , and anything else.
@@ -27,20 +27,81 @@ point changes
2727</p >
2828<br >
2929
30- ## How it works
30+ # Status
31+ :warning : :warning : :warning :
32+
33+ ** Project in progress right now. Please wait for 1.0.0 version.**
34+
35+ # TODOS
36+
37+ - [ ] Documentation
38+ - [ ] JSDoc comments
39+ - [ ] Vue, RN, Solid bindings
40+ - [ ] Examples on all frameworks
41+
42+ # Installation
43+
44+ ** Using npm**
45+
46+ ``` sh
47+ npm i dotto.x
48+ ```
49+
50+ ** Using yarn**
51+
52+ ``` sh
53+ yarn add dotto.x
54+ ```
55+
56+ # Base usage
57+
58+ ## Atomic stores
59+
60+ ``` ts
61+ import { createAtom } from ' dotto.x'
62+
63+ const userName = createAtom (' John' )
64+
65+ userName .listen (value => {
66+ // do something
67+ })
68+
69+ userName .set (' John Constantine' )
70+ ```
71+
72+ ## Mutable stores
3173
3274``` ts
3375import { createStore } from ' dotto.x'
3476
35- const store = createStore ({ some: { path: 0 } })
77+ const user = createStore ({ name: ' John ' })
3678
37- store .listen (' some.path' , (path , value ) => {
38- // path - some.path
39- // value - 1,2
79+ user .watch (' name' , value => {
80+ // do something
4081})
4182
42- store .set (' some.path' , 1 )
43- store .set (' some.path' , 2 )
44- store .set (' some.path' , ' error' ) // type checks throw error, because 'some.path' most be a number.
83+ userName .set (' name' , ' John Constantine' )
4584```
4685
86+ ## Combine stores
87+
88+ Subscribe to store or part of stores using take. Take — computed operator.
89+
90+ ``` ts
91+ import { createStore , computed , take } from ' dotto.x'
92+
93+ const user = createStore ({ name: ' John' , id: ' some_id' })
94+ const projects = createStore ({
95+ some_id: { name: ' Portfolio' },
96+ some_other_id: { name: ' Hell' }
97+ })
98+
99+ const targetProject = computed (() => {
100+ let userId = take (user , ' id' )
101+ return take (projects , userId )
102+ })
103+
104+ targetProject .subscribe (value => /* do something */ )
105+
106+ user .set (' id' , ' some_other_id' )
107+ ```
0 commit comments