Skip to content

Instantly share code, notes, and snippets.

@plecong
Last active June 1, 2017 17:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save plecong/6afd1bee53bc8e9b1e130040387ec48d to your computer and use it in GitHub Desktop.
Save plecong/6afd1bee53bc8e9b1e130040387ec48d to your computer and use it in GitHub Desktop.
Redux Command

Redux Command

A version of Flux on top of Redux with a (hopefully) simpler API. When approaching Redux, for such a simple yet powerful library, there are quite a few concepts to learn including actions, action creators, reducers, stores, middleware, thunks, etc. Furthermore, with so many parts, organizing them becomes a problem (see Ducks).

Redux Command attempts to simplify the number of concepts and also provide an obvious connection between them to promote easier use while still allowing for the full power of Redux.

Ultimately, Redux Command applies the Command pattern to package the change against a store (formerly reducer) and the parameters for that change (formerly the payload in an action) together. This is slightly different than the original Flux and Redux in that the Action could be seen as an "event" in an Observer pattern where the store then reacts to the "event" with a "handler" (the reducer function).

Design Goals

  1. Built on top of Redux while allowing access to Redux for legacy compatibility
  2. Maintain fundamental Flux concept of unidirectional data-flow
  3. Leverage learnings from other view technologies (e.g. WPF)
  4. Type(script) aware
  5. Colocation of Actions and Reducers (combined into Commands)

Nice to Haves

  1. Built-in async support
  2. Multiple stores for different domains
  3. First-class support for stores that are collections
  4. A command can trigger changes in multiple stores
  5. A command can sequence changes in stores
  6. A means to create "command creator" functions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment