Observable.hasObservers() is still true after removing all the observers

Observable.hasObservers() is still true after removing all the observers.

image

To reproduce :

Maybe i’m missing something ?

To avoid issues when iterating the observers we use setTImeout to remove, but we mark the observers as deleted in case you run it again. This is a simple solution:

Observable.observers | Babylon.js Playground (babylonjs.com)

1 Like

Oh, and the reason you don’t see the object after opening it is because of how the dev console is working. when you output it, it has a member, but when you open it it doesn’t. Clone the array and you will see the observers there as well.

2 Likes

Thank you @RaananW !

We discussed with the team and finally concluded it was more a bug than anything else. So we will modify hasObservers so that it does not take into account deleted observers that would still be in the list:

2 Likes