All:
I am pretty new to React. When I follow its TodoMVC example, there is one question confuses me so much:
Inside TodoApp component, it registers its handler using TodoStore.addChangeListener:
componentDidMount: function() {
TodoStore.addChangeListener(this._onChange);
},
_onChange: function() {
this.setState(getTodoState());
}
And let CHANGE_EVENT in TodoStore.addChangeListener to trigger that _onChange callback:
addChangeListener: function(callback) {
this.on(CHANGE_EVENT, callback);
},
What confuses me here is:
How "this.on" knows the context of that callback( I mean how does it remember the "this" from _onChange )
What if there are multiple TodoApp register their _onChange, so the todoStore will maintain a list of all callbacks?
Thanks