-
Notifications
You must be signed in to change notification settings - Fork 11
Description
As I can't comment on he readme I'm using this issue.
Great write up of Javascript Plugin Reload Hook solutions.
I wrote the original __reload hook (alexisvincent/systemjs-hot-reloader#23) but I agree that this complicates things, as it runs after the regular initiation is run, you'll need hooks to adapt what's already initiated (like Redux's replaceReducer).
You might find the following discussion interesting: alexisvincent/systemjs-hot-reloader#34
For example Proposal #3 would give you access to the old module, but a good point of mikz is that this requires you to make your state public (export it).
I like my last idea: alexisvincent/systemjs-hot-reloader#34 (comment), which I turned into a simple utility: simple systemjs-hot-reloader-store utility. This enables you to use the old state during the regular initiation of the module and doesn't require exporting the state. It also doesn't require any special hooks.
It's big downside however is that you manually need to pick a unique name.
Maybe there is a way to enable every module to import a @hotState
, which is a
unique object per module. This can then used to store state in and on reload, when it's there, it can be used for rehydration. This fixes the unique name issue and the module author can decide if he want's to store anything and what is stored. (I stole the name from: alexisvincent/systemjs-hot-reloader#34 (comment))