okfn / opendataeditor

No-code application to explore and publish all kinds of data: datasets, tables, charts, maps, stories, and more. Forever free and open source project powered by open standards and generative AI.
http://opendataeditor.okfn.org
MIT License
149 stars 18 forks source link

Migrate Application store to the global/static one #447

Closed roll closed 20 hours ago

roll commented 3 days ago

Historically, the application was started as a set of independent components (to be shared for Frictionless Universe), and the modular pattern was used consistently for even high-level components like applications/controllers. Now we have some time to refactor it, so using a global/static store will bring many pros:

Untitled_ Jun 28, 2024 11_13 AM.webm

It's a massive change that would be totally dangerous to do in JavaScript without tests in-place but in TypeScripe we can be 98% sure that it's properly migrated as it won't pass type checking otherwise.

Anyway, I added an example of testing for the store -- it will be good to write tests ASAP.

roll commented 3 days ago

Interestingly, why rollup is not catching the import config from Vite. I'll investigate. Upd. the vite configs are different (desktop/client)

cloudflare-pages[bot] commented 3 days ago

Deploying opendataeditor with  Cloudflare Pages  Cloudflare Pages

Latest commit: 140ee94
Status: ✅  Deploy successful!
Preview URL: https://e4a5743f.opendataeditor.pages.dev
Branch Preview URL: https://430-consolidate-stores.opendataeditor.pages.dev

View logs

pdelboca commented 22 hours ago

Looks good @roll ! A lot cleaner :)

Agree that we need to have tests ASAP. Now that we are finishing the workflows we could start implementing them.

roll commented 20 hours ago

Thanks! I use this approach in new projects, and I think it's more readable/maintainable compared to the default Zustand patterns. Also immer allows stop thinking about the way state was changed (like creating new copies of array/object to trigger re-renders) and just program the changes itself