question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Provide destroy method

See original GitHub issue

Feature request

I can subscribe on some events inside module, but I can’t unsubscribe with current API

For example, crosstab module subscribes on storage event and this logic will work whole page lifecycle, and I don’t have mechanism to stop it.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
majo44commented, Nov 6, 2019

Hi, I think this is responsibility of module author to allows “destroy” module. We can imagine multiple different scenarios where the store have to support destroy but only partially, so covering them all from the storeon top level will be hard and will requires changes of api. In my project I’m using such pattern for modals:

let modalModule = store =>
    store.on('openModal', () => {
           const destroy = [
                store.on('confirm', ...
                store.on('help', ...
                store.on('closeModal',() => destroy.forEach(i => i())]
    }

Example on @jeetiss code: Edit destroy-storeon or Edit destroy-storeon

0reactions
aicommented, Oct 29, 2019

I realize that I can wrap over createStore function and create destroy method without modifying core logic

Do you need to use Storeon plugins or you write your own? If you have only own modules, this way will work for you.

If you need a “destroy” support in standard plugins, we need something like @destroy event (but still it will be awesome to move it to some submodule, since it is rare feature).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Spring core. Default @Bean destroy method - Stack Overflow
One of the methods it provides is the destroy method being called by Spring. This way you don't have to provide any implementation...
Read more >
Spring - init() and destroy() Methods with Example
destroy -method is bean attribute using which we can assign a custom bean method that will be called just before the bean is...
Read more >
Spring init-method and destroy-method example - Mkyong.com
In Spring, you can use init-method and destroy-method as attribute in bean configuration file for bean to perform certain actions upon ...
Read more >
How to use init-method and destroy-method attributes in ...
Program to demonstrate how to use init-method and destroy-method attributes in Spring Configuration file.
Read more >
Destroying Components - Kendo UI for jQuery
The destroy method: Deletes the component instance (client object). As a result, the component is no longer accessible and all its event handlers...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found