Giter Club home page Giter Club logo

Comments (7)

emmenko avatar emmenko commented on June 2, 2024

Sounds like a good solution!

from redux.

hugooliveirad avatar hugooliveirad commented on June 2, 2024

Looks good for me too. I like the ideia of passing the store to get it's state. Passing a string to do that is something that I dislike in e.g. Flummox.

ES6 Map api is simple enough too.

πŸ‘

from redux.

gaearon avatar gaearon commented on June 2, 2024

Maybe shouldn't even pass an ES6 Map and instead pass just the read function. This reinforces that the state is meant to be read-only, doesn't introduce a dependency on a specific type and also forbids weird things like enumeration.

export function incrementIfOdd() {
  return (dispatch, read) => {
    if (read(counterStore) % 2 === 0) {
      return;
    }

    dispatch(increment());
  };
}

from redux.

emmenko avatar emmenko commented on June 2, 2024

πŸ‘

from redux.

gaearon avatar gaearon commented on June 2, 2024

If somebody wants to PR this, I'll take it.

from redux.

gaearon avatar gaearon commented on June 2, 2024

If you do decide to PR this, note that internally we still need to use string keys for storage. This is because functions are hot-swapped on every file save, and their identities change. This is why we have an { key: string -> state: object } object for state, and a { store: function -> key: string } ES6 Map for mapping Store functions to state keys.

from redux.

gaearon avatar gaearon commented on June 2, 2024

Fixed via ac1be83, thanks!

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.