Getting Started
Three functions#
GlobX contains only three functions. Two functions has only one parameters, and one function has no parameters. That it. If you learn that, you know everything about GlobX.
newStore- Usually called once for a project with you initial store.updateStore- Called after every change to your store, when you wish to rerender automatically the required components.useRenderIfIChange- Called in every component that needs to be updated based on specific paths in your store
That It! No High-order-components. No Providers, connectors, modifiers, decorations, selectors or other smells.
Installation#
First you have to install GlobX
Creating your first store#
Create the store file mystore.js (or mystore.ts)
The store may contain primitive values, objects, functions, arrays, Dates or whatever you wish. is just a regular javascript object.
tip
If you need you can create more than one store
Then you can show values from the store and update or call functions in your store:
To be sure that your component will render when value changed you have to do 2 things:
- call the function
updateStoreafter changing the store. - Call the function
useRenderIfIChangeand give it an array of values that should be inseted. One of the those values changed, the component will rerender.
note
That It! Now you know everything about how to use GlobX!
Mutating objects#
Another examples of a simple todo list. You don't have to clone the array:
The last thing to know is that you have auto-complete everywhere:

All IDE smart language features like Renaming Symbols, or find all references are working.
Async operations#
What about async operations? It's working out of the box:
Sharing Logic#
If you wish to have a specific logic of mutating to the store (actions), you can add functions to the store and call them:
You can also create async functions.
Multi stores#
Although probably most of the projects will use one global store. You are free to create multi stores, and use each or both of them in any component.
tip
You can call updateStore as many time you wish. GlobX smart enough to executing it only once per rendering cycle.