Coder Social home page Coder Social logo

Thunk support? about reduxtron HOT 4 CLOSED

goosewobbler avatar goosewobbler commented on July 20, 2024
Thunk support?

from reduxtron.

Comments (4)

goosewobbler avatar goosewobbler commented on July 20, 2024 1

Thanks a lot for the information, it's an interesting set of problems for sure. As for my specific use case I have been considering some ideas about how to handle these thunks, now looking at implementing a completely different approach to the state management. I'll close this now as my questions have been answered.

from reduxtron.

vitordino avatar vitordino commented on July 20, 2024

Hey again @goosewobbler,

thanks for the kind words (:
i never publicized much this library (i still believe on much of it’s value tho)
if i ever find the time to polish it, i will try to find some energy to properly publish it


reduxtron rely on a ipc "bridge" that can only pass serializable values between processes.

as thunks have promises — not easily serializable — and as the redux store lives in the main process: we can’t send thunks from the renderer process (inside the frontend) to the store.

i haven’t used RTK much, but i believe it export hooks that fire those thunks..
a possibility to overcome this would be to keep RTK only on the main process, and write hooks (if you use react) that fire simple (serializable) actions and return the result of the specific selector.


i sketched something similar (but inspired by swr) on the demo app, where i could fetch both URLs and the user’s filesystem:

it was more of a long-running exploration tho
on a production app i’d probably rely on a maintained/well tested library for doing this request/caching bit (like RTK)

so i believe it might be possible to use much of RTK, but tweak the consumption (dispatch/reducer) part on the frontend to be "reduxtron friendly"


spoiler: different than electron-redux on reduxtron the frontend doesn’t need redux (:

from reduxtron.

vitordino avatar vitordino commented on July 20, 2024

additional investigation needed: maybe there’s a way of serializing promises across ipc? 🤔

i see some libs (and some issues) regarding this possibility..

i’ve still haven’t had the need, but might be possible and help with your issue


if we ever accomplish this feat, it would likely be an reduxtron option.
as it would add extra layers of serialization/deserialization because electron’s ipc demands html’s structured clone algorithm

from reduxtron.

vitordino avatar vitordino commented on July 20, 2024

it’s interesting for sure!
if you only use redux for RTK and consume directly using the hooks on the frontend
maybe it makes sense to just send the saved state (request cache) to the main process
— eg.: using a middleware on the frontend to call the reduxtron’s setState function 🤔 (having 2 redux stores)

it really depends on how/what you use, the ergonomics you need etc

from reduxtron.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.