@@ -112,26 +112,35 @@ userStore.address.assign({
112112
113113Note: the` assign ` method only exists on object data type
114114
115- ##Using set withCallbacks
115+ ##Set withcallback functions
116116
117- When passing a callback to to the ` set ` function, the type of callback you need to pass depends on the state datatype.
117+ The ` set ` function can accept a value or a callback function
118118
119- The types fully reflect which type of callback is required and therefore your IDE guide you.
119+ Set value example:` counterStore.set(5) `
120+ Set callback function example:` counterStore.set(()=>{...}) `
120121
121- ###using` set(draft=>{}) ` with objects/arrays
122+ ###Datatype differences summary
123+
124+ The type of callback function changes depending on the state datatype.
125+
126+ ** Objects/Arrays** : directly modify the draft, don't return anything
127+ ** Primitives** : get previous value, return new value
128+
129+ (The types fully reflect which type of callback is required and therefore your IDE will guide you.)
130+
131+ ###Object / Array set callback details
122132
123133Calling` .set ` on an object/array uses immer under the hook, allowing you to mutate a draft copy of the state while maininaining immutability.
124134
125135``` tsx
126136const userStore= store ({ name:' John' , age:20 });
127137
128- // settings objects uses immer
138+ // draft object uses immer
129139userStore .set ((draft )=> {
130140draft .name = ' Jane' ;
131141draft .age = 30 ;
132142});
133143
134- //
135144const todosStore= store ([
136145{ id:1 , text:' write docs' },
137146{ id:2 , text:' sleep' },
@@ -141,35 +150,24 @@ todosStore.set((draft) => {
141150draft .push (' another task' );
142151});
143152
144- todosStore .set (draft => {
145- cosnt firstTodo = todosStore [0 ];
146- firstTodo .text = " new text"
147- })
153+ todosStore .set (( draft ) => {
154+ const firstTodo= draft [0 ];
155+ firstTodo .text = ' new text' ;
156+ });
148157```
149158
150- ###Using ` set(preValue=>...) with primatives
159+ ###Primitives set callback details
151160
152161Calling` set ` on other data types behaves slightly differently.
162+
153163You are given the previous value of the property and you must return the new value from the callback.
154164
155165``` tsx
156166userStore .age .set ((prevAge )=> prevAge + 1 );
157167```
158168
159- ###Key differences between using set callback
160-
161- - objects/arrays:
162-
163- - you can directly modify the draft and you dont need to return anything
164-
165- - primative values:
166-
167- - gets the previous value of the property, you must return the new value from the callback
168-
169169##Additional notes:
170170
171- - calling ` .set(value) ` on arrays/object behaves the same as other values. The difference only arises when passing a callback to the ` set ` function.
171+ - Non-draftable values (e.g., MediaRecorder or window) will be considered as primitive values
172172
173173- Since` @davstack/store 1.3.0 ` root level array stores are fully supported
174-
175- - You no longer need to consider the limitations of immer as non-draftable values eg MediaRecorder or window will default to regular zustand setters.