tfrydrychewicz / aurelia-flux

Flux dispatcher plugin for Aurelia
MIT License
74 stars 17 forks source link

Child route view model detach is causing 'deregistration' with dispatcher. #4

Closed acidbluebriggs closed 9 years ago

acidbluebriggs commented 9 years ago

When a child view is detached from it's parent, the next activated child view will no not receive messages from the dispatcher.

The issue is simple. I have a parent navigation menu. Clicking on that menu displays a child view. That child view’s data is populated by an action being invoked, which calls a mock service. The result of that service is retrieved from the action, the dispatcher is notified, then the dispatcher dispatches to the handlers (the store in this case). The store then notifies the child view that a new item has been selected. This works fine. But, selecting another item from the parent still does everything correctly except notifying the view model. I have found that removing the call to FluxDispatcher.instance.unregisterInstanceDispatcher(instance[Symbols.instanceDispatcher]) will solve the problem, but a memory leak occurs (of course).

I haven't been able to nail down why it is not reregistered. I've even tried to manually register the handler (dispatcher.handle(...)) in activate(), but that doesn't work either.

I have a plunk set up, but currently I cannot get it to run there. The plunk seems to fail at the registration of handlers in the flux-plugin. You can get to the plunk here. The code is available on github @ https://github.com/acidbluebriggs/aurelia-flux-example. This should run fine after the ceremonious npm install, jspm install.

tfrydrychewicz commented 9 years ago

I've just pushed version 0.1.4 and closed Issue #2. Could you please give it a try and see if that helps.

tfrydrychewicz commented 9 years ago

It is going to be resolved in #6

acidbluebriggs commented 9 years ago

The demo application now behaves as expected. Closing issue.