flux icon indicating copy to clipboard operation
flux copied to clipboard

AppDispatcher.register(function(action) not called

Open xkangai opened this issue 11 years ago • 2 comments

2015-05-07 15 49 00 2015-05-07 15 49 28 2015-05-07 15 50 24 2015-05-07 15 50 39

hi, i just started to use flux and encountered a very wired bug. today I tried to copy some of the code in the flux-todomvc project at https://github.com/facebook/flux/tree/master/examples/flux-todomvc After I dispatch my action, the AppDispatcher.register(function(action)) is NOT called. Can anyone tell me why?

xkangai avatar May 07 '15 15:05 xkangai

It seems the Flux.Dispatcher (or AppDispatcher in your case) is not a singleton by itself. Thus the two places where you require it (action and store), get different instances of Dispatcher. You need to wrap it in a custom singleton implementation.

My question: why is it not a singleton by itself? I am submitting a PR for the same.

Edit: Just figured this is not correct. Flux.Dispatcher is not a singleton by design. AppDispatcher on the other is a singleton as modules are cached if the default export is a class instance. Thus this is not the issue. Apologies for the false alarm.

abhinavrastogi avatar May 15 '15 10:05 abhinavrastogi

Sounds like this is resolved, re-open if not!

kyldvs avatar Jul 28 '15 15:07 kyldvs