Giter Club home page Giter Club logo

Comments (7)

gaearon avatar gaearon commented on June 2, 2024 24

I thought of that, but this kind of screws the replay thing. (AFAIK you can't serialize and then deserialize symbols.) I want to pass them around for devtools, localStorage persistence, etc.

from redux.

tbranyen avatar tbranyen commented on June 2, 2024 8

@gaearon I see what you mean, that is very true. For my use case it won't be a problem, and I've submitted a patch request for redux-logger here: LogRocket/redux-logger#106

(Sorry for spamming this particular issue, but I think it's useful for others looking to use Symbols).

from redux.

gaearon avatar gaearon commented on June 2, 2024 7

You can't take an array of actions that use symbols, serialise them to JSON, save to localStorage, and later deserialise and replay them in a different browser session.

from redux.

ooflorent avatar ooflorent commented on June 2, 2024

You're right you cannot deserialize a Symbol. I've missed that point.

from redux.

gaearon avatar gaearon commented on June 2, 2024

I say let's keep them strings for now and revisit if there are ways to get around (de)serialization problem.

from redux.

tbranyen avatar tbranyen commented on June 2, 2024

I might be confused here, but what do you mean by "cannot deserialize a Symbol"?

const INCREMENT_COUNTER = Symbol('INCREMENT_COUNTER');

console.log(String(INCREMENT_COUNTER)); // Symbol(INCREMENT_COUNTER)

Wouldn't this be perfectly ideal for Redux? The ability to have identically named action types that are namespaced. I'm absolutely hating the fear that action types are overlapping since everything is global.

from redux.

tbranyen avatar tbranyen commented on June 2, 2024

I just tried using a Symbol and thankfully it works excellent with Redux! The only error that came up was with redux-logger, so I'll narrow down the error and submit a patch (if one isn't already there).

from redux.

Related Issues (20)

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.