Created
August 26, 2015 12:06
-
-
Save avesus/376d5eb4ee6718d869af to your computer and use it in GitHub Desktop.
What Flux really is
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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