something like onDelete() callback in JS?

Zachary Seldess's icon

Hi guys,

I'm still primarily working in Max5, FYI.

I've run into a scenario where I'm occasionally creating objects in the global Javascript space (i.e. someObject = new Object();), and looking for a way to automatically delete them (since garbage collection will never do so in this case, I believe).

So, I'm wondering, is there an onDelete() type of callback that can be used when a [js] object gets deleted? Something like closebang, but called inside the object before the object gets deleted, providing a way to do some cleanup...

best,
Zachary

oli larkin's icon

notifydeleted() ?

Zachary Seldess's icon

I only see notifydeleted() mentioned in one Java tutorial and can't find any mention of it in the JavaScript documentation (Max5). But it works! Thanks Oli.

best,
Zachary

Emmanuel Jourdan's icon

Thanks for mentioning it. We'll have it documented. Basically the function notifydeleted is called before your js/jsui object disappear so you can do some cleaning. There's some examples in the examples/jitter-examples/javascript folder.