Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Proof of concept of mobx #925

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

feat: Proof of concept of mobx #925

wants to merge 1 commit into from

Conversation

ptbrowne
Copy link
Collaborator

@ptbrowne ptbrowne commented Dec 5, 2022

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.

Our world in data use mobx.
Linear.app use mobx.

@vercel
Copy link

vercel bot commented Dec 5, 2022

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)

Copy link
Collaborator

@bprusinowski bprusinowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fantastic, I really like this approach 🎉 We should try to incorporate this in the app in the future, as mentioned in PR's review 👌

app/pages/_mobx.tsx Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants