I know javascript does not have destroy method, but my object needs to know when it ceases to exist.
class MyObject
{
constructor()
{
this.interval = setInterval(this.checker, 5000);
}
checker()
{
// Stuff
}
beforeDestroy()
{
clearInterval( this.interval );
}
}
I would like to clear a timeout and an interval before it's being destroyed. I'm not finding it, I'm assuming it is not possible but I would like to be sure. Any node.js version, experimental or using custom module is ok.
MyObjectis used.