Thoughts on Redux/RTK

Redux/RTK is a high level Javascript application abstraction that has widespread adoption. Having hand plumbed RTK instances to Moqui entities a number of times now, I find myself fantasizing about a facility that would automatically generate the RTK slices from the Moqui data model. Having this automation for service definition would be a huge time saver, especially if it was integrated into Moqui cache clearing by default (ie. server side events can trigger reloads in the client).

Redux is often regarded as a React technology but it is not, in fact, dependent on React. It should be possible to integrate the resulting Redux application into a variety of frameworks, including native apps. Redux also has sophisticated in-browser debugging tools that are worth a look. I can attest to its ability to resolve certain complicated callback event loop problems in the browser.

Anyone else using Redux?

1 Like

I do have a fork that could make this better. It lets you define whether or not fields in a data document are mutable or readable. Data documents could then be sent through websocket to the client and back with metadata about what the client can change on server side.

It could even be used for mobile apps as metadata of what they can store and sync back up to the server for offline modes.

I’m not sure what an RTK slice is, but potentially generating a data model wouldn’t be that hard. On a server you could parse xml, with extensions, and generate a object model in memory. That could then be used to generate sql or whatever context is needed.

An alternative to this would be to create a mechanism in Moqui for exposing the EntityDbMeta in an application specific api that is in a format that is consistent across applications. Then a client library could be built to query that api to generate necessary in memory or generated code files like amplify does.

Take with this what you will. These are just some thoughts

It looks like some of this may be ready to go. There is apparently support for generating the Redux schema from OpenAPI. redux-toolkit/packages/rtk-query-codegen-openapi at master · reduxjs/redux-toolkit · GitHub

1 Like

Sick that’s cool. A bit of modification, and it should work well