Add store.destroy() to remove event listeners, unsubscribe from store listeners or cleanup state.
I have already opened a PR (#57) for this, but some integration is still missing and I would like a review + feedback on the implementation (in case you are interested in merging it).
Synopsis
This feature has 2 interfaces:
return a function from bundle.init()
explicitly declare bundle.destroy()
Both interfaces also work together. It is a 1-way final method - no option to revert or re-initialize the store again. See test/destroy.js for reference.
Background
I am currently working on a distributed micro-frontend application. Every App is mounted or unmounted from a Shell application. On mount, the (micro) app is instantiated and for unmount, it is destroyed. With the reactor bundle (and others) the store.subscribe call leaves artifacts, like APP_IDLE, that are executed even when the App is removed already. Without this change, the store would never get garbage collected. Additionally, want to use it to cleanup other DOM event listeners.
Hi @HenrikJoreteg
TL;DR
Add
store.destroy()
to remove event listeners, unsubscribe from store listeners or cleanup state.I have already opened a PR (#57) for this, but some integration is still missing and I would like a review + feedback on the implementation (in case you are interested in merging it).
Synopsis
This feature has 2 interfaces:
bundle.init()
bundle.destroy()
Both interfaces also work together. It is a 1-way final method - no option to revert or re-initialize the store again. See
test/destroy.js
for reference.Background
I am currently working on a distributed micro-frontend application. Every App is mounted or unmounted from a Shell application. On mount, the (micro) app is instantiated and for unmount, it is destroyed. With the reactor bundle (and others) the store.subscribe call leaves artifacts, like APP_IDLE, that are executed even when the App is removed already. Without this change, the store would never get garbage collected. Additionally, want to use it to cleanup other DOM event listeners.