Closed rudionrails closed 5 years ago
This is really clean, I dig it!
I particularly like the pattern of returning the "unsubscribe" version of the function from adding event listeners and optionally returning a destroy method from init.
I think the only thing missing here is just some documentation for the /docs
folder.
But overall, very nice.
Glad you like it so far. I would still need some help with this stuff here (may be affected by it)
Otherwise, I can add documentation on this for sure
Updated docs to cover store.destroy
, bundle.destroy
and bundle.init
. Would be happy for a merge now :)
I'm still on vacation in Sweden. Thanks for your patience. Will try to review properly and merge sometime after I get back.
hey @rudionrails! I finally had a chance to do this.
I ended up actually removing the explicit bundle.destroy()
support. Instead you have to return a cleanup method from init()
.
I did this because I didn't want to introduce multiple ways to do the same thing. And especially in the case of event listeners it seemed more likely that you've have the relevant listeners available in scope by doing it in init. Plus... it more closely matches patterns established elsewhere in the code.
Hope that's ok.
Anyway... released at 26.0.0
Thanks again!
Perfect. Thanks :)
TL;DR
store.destroy()
to remove event listeners, unsubscribe from store listeners or cleanup state.Synopsis This feature has 2 interfaces: either return a function from
bundle.init()
or explicitly declarebundle.destroy()
. Both also work together. It is a 1-way final method - no option to revert or re-initialize the store again. Seetest/destroy.js
for reference.