feat: Proof of concept of mobx
This is a proof of concept of how mobx could help with state management and computed values.
See the _mobx page.
A cube class is created and made observable. It is responsible for holding and loading the data. It is observable so components decorated with observer will automatically react to changes.
In the demo, hierarchies are computed "lazily", and integrated in the chart. Component relying on the hierarchy are automatically re-rendered when the data comes in. The list of dimensions and measures shown is based on the "components" computed property in the cube.
Nice things with mobx:
- Observables can be mutated without losing observability (see how "loading" states are changed)
- Computed values can be calculated (see dimensionByIri or the components values)
- When a component is wrapped into observer, it will automatically re-render if one of the accessed values is changed
In the end, I think it could replace both the redux / immer and the zustand, and also the chart states (where computed values would be clearer than the chain of useMemo that we use). I think urql is here to stay though as it still delivers a client cache for network requests, and this can be helpful (if you reinstantiate a new cube based on the same IRI, the cache will be hit). Urql and mobx seem to be playing nicely enough in the POC.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
| Name | Status | Preview | Updated |
|---|---|---|---|
| visualization-tool | ✅ Ready (Inspect) | Visit Preview | Dec 5, 2022 at 4:05PM (UTC) |