milankinen/livereactload

Add module.onAnyUpdate hook that triggers every time after reloading event

tancredi opened this issue · 1 comments

Firstly, thanks for building this tool - I'm trying to improve the build / watch workflow of an app I'm working on and being able to move back to Browserify makes a huge difference.

Now, here's the issue: I have a fairly complex app which uses custom routing and a custom router module - the routes and views are not declarative, so they don't get included directly in the react renders but they get pulled out of a JS object elsewhere, with their associated components.

The component modules get reloaded all right, though they don't get re-rendered for whatever reason. My understanding is onUpdate only is called on the module it's scope within, while what I'd like to have is a hood that is triggered on 'any module update' to be able manually trigger a re-render.

It would be pretty repetitive to add an extra line to each of my views to communicate externally a re-render is due. A simple global callback hook for all module reloads event would be enough for this kind of use-case, and I'm sure could come handy to other people, too. Thoughts?

Hello @tancredi!

Yes, that is a very good proposal and doable pretty easily! 👍 First you should add new onAnyUpdate method to the module here which adds some kind of listener to reload events. And after reload has happened, invoke those listeners here.

I'd gladly accept any pull request adding this feature! 😄