Skip to content

Instantly share code, notes, and snippets.

@denisnazarov
Last active August 29, 2015 14:21
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 denisnazarov/12e9933d0d1b95be13ed to your computer and use it in GitHub Desktop.
Save denisnazarov/12e9933d0d1b95be13ed to your computer and use it in GitHub Desktop.
Flux Notes
FLUX:
Dispatcher, Stores, Views
Action Creators: dispatcher helper methods
Dispatcher:
- a registry of callbacks into the stores and has no real intelligence of its own
- a mechanism form distributing actions to the stores
- each store registers itself and provides a callback
Stores:
- contain the application state and logic
- they manage the state of many object
- stores manage the application state for a particular domain within the application
- exhibits characteristics of both a collection of models and a singleton model of a logical domain
- registers itself with dispatcher and provides it with a callback, callback receives the action as a parameter
- a switch statement based on the action's type is used to interpret the action and to provide the proper hooks into the store's internal methods
- after the stores are updated, they broadcast an event declaring that their state has changed, so the views may query the new state and update themselves
Views and Controller Views:
- listen for events that are broadcast by the stores that it depends on and rerenders
Actions:
- a method that allows us to trigger a dispatch to the stores, and to include a payload of data
=========
Distinction between UI State and Application State (e.g. UI state is in input, becomes application state after hitting Submit)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment