You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
this on('init', ()=>...) registers an anonymous callback, so i have no ways to off() it either.
To solve the issue, there are 2 folds:
(1) To just address the issue i am having, it would be nice if we have a clearCallbacks('init') to call, or off('init') without a callback can just delete all callbacks associated to this key (wait isn't that going to wipe callbacks if the user calls off('init', callback) with a null-callback? I dunno, clearCallbacks() may increase the package size tho, or does it not?)
(2) Is to just fix the GameObject destroy code, to properly clear the callback, probably adding 1 more named function so that it can call off() properly.
Quote slack message:
Oh really? so you are saying it is probably a bug that init did not get cleared?
The text was updated successfully, but these errors were encountered:
Anyway, my work-around is to just use a Pool, just that i need the Pool object to also be a GameObject, for parent position calculations, so i write it myself instead of using the kontra Pool
Um... what if your event system supports once('init', ()=> ...), so it will auto clear the callbacks once emit('init') fires. that would be nice to deal with anonymous callbacks.
I am making a simple particle system with the mind that garbage collection shouldn't be a big issue, so i didn't bother to use Pool.
However,
removeChild
isn't sufficient to remove references,setting
this._uf
to null helps, but there are still other lingering references.So i opened the profiler:
turns out the
init
callback still remembers the sprite, as written in https://github.com/straker/kontra/blob/main/src/gameObject.js#L270-L272this
on('init', ()=>...)
registers an anonymous callback, so i have no ways tooff()
it either.To solve the issue, there are 2 folds:
(1) To just address the issue i am having, it would be nice if we have a
clearCallbacks('init')
to call, oroff('init')
without a callback can just delete all callbacks associated to this key (wait isn't that going to wipe callbacks if the user callsoff('init', callback)
with a null-callback? I dunno,clearCallbacks()
may increase the package size tho, or does it not?)(2) Is to just fix the GameObject destroy code, to properly clear the callback, probably adding 1 more named function so that it can call
off()
properly.Oh really? so you are saying it is probably a bug that
init
did not get cleared?The text was updated successfully, but these errors were encountered: