Open lishine opened 4 years ago
Thanks for you feedback!
I have only thought the pattern for the store which is public for all components or private for some components.
const Todo = {
state: {
items: ['Install react-model', 'Read github docs', 'Build App']
},
actions: {
add: todo => {
return state => {
state.items.push(todo)
}
}
}
}
Pattern 1
const { useStore } = Model({ Todo })
This usage expose the store for all components, you can visit or update it by
const [state, actions] = useStore('Todo')
Pattern 2
export const { useStore } = Model(Todo)
you can also update the component which import the useStore ( local for a component group )
It becomes a modular variable if you use it inside useEffect scope because other components cannot get the useStore and the anonymous name of the store
Can you show your example or PR in more detail? to be honest, I am not very clear about the feature concept you mentioned above.
I have a:
First of all, it is great great lib! After many others, I appreciate all the features here!
Another documentation that I can add, is the neat feature - as an example if you push into array but in the component you use the first element, then the component won't be updated.
[ x] Documentation improvement. Creating a PR if you canπ.
Please tick the appropriate boxes. Feel free to remove the other sections.
Please be sure to close your issues promptly.