Skip to content

Instantly share code, notes, and snippets.

@avesus
Created August 26, 2015 12:06
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 avesus/376d5eb4ee6718d869af to your computer and use it in GitHub Desktop.
Save avesus/376d5eb4ee6718d869af to your computer and use it in GitHub Desktop.
What Flux really is
The Dispatcher is singleton visible for all Views with its dispatch() method.
(Note: it visible for Stores with its register() method).
View uses The Dispatcher to call its dispatch() method specifying eventName and eventItemData
Store:
Domain A
Store A : EventEmitter
Collection Model A1
Tree Model A2
Simple Model A3
Domain B
Store B : EventEmitter
Simple Model B1
Store registers its handlers in The Dispatcher.
Handler receives emitted in dispatch() data with event name and data and, if it is his event, MODIFIES corresponding data
and emits an event with EventEmitter.
Important: the event about model change should not contain model data, just 'changed' event.
View will completely re-render when the model changes.
COMPONENT listens for 'change' event when it is first CREATED (on unmount it unsubscribes).
Most simple case for onModelChanged() handler is call of RENDER!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment