Closed MAYDAY1993 closed 6 years ago
If you dig a bit in the code,
listenTo
is made of function(listenable,callback,defaultCallback){
Where if defaultCallback
exists it goes and fetches the initial state (fetchInitialState
) from the listenable, and feeds the data back into defaultCallback
And fetchInitialState
has the next explanation:
/**
* Used in `listenTo`. Fetches initial data from a publisher if it has a `getInitialState` method.
* @param {Action|Store} listenable The publisher we want to get initial state from
* @param {Function|String} defaultCallback The method to receive the data
*/
So if the store you are about to listen to, has the getInitialState
, you can pass defaultCallback
to grab the data retuned from getInitialState
and do something with it.
@eek thank you so much 😄
hi,I looked through the docs about Reflux.listenTo's usages in here and find that there are two arguments:one is listenable,the other is callback,but later I find out that there exists a third argument meaning defaultCallback ,I can't find related docs ,only this pr : pr. My problem is :what's the usage of defaultCallback,when to call this function and is there any ducuments to refer to?Thank you 😃