Hi,
I’m not sure if it’s a bug or myself doing a bad usage of observables, but I have an issue by listening observable in a loop.
In a loop, only the last added callback is called when doing a .notifyObservers()
Here’s a Playground example with the mesh.onDisposeObservable
observable.
Thank you !
It is JavaScript thing: use “const” instead of “var”: https://playground.babylonjs.com/#XUC7O1#2
See also.
1 Like
This is probably the solution: https://playground.babylonjs.com/#XUC7O1#5
I would expect that sphere.dispose does cleanup the observables for you. And maybe your extra call to observer.dispose messes up the cleanup loop?
This: https://playground.babylonjs.com/#XUC7O1#7 (as per latest comment)
The changes are that Observable.remove() has now a defer prop that is set to false by default, so giving it true
fix the problem
1 Like