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

**URL:** <https://forum.babylonjs.com/t/observable-hasobservers-is-still-true-after-removing-all-the-observers/35987>\
**Category:** Bugs\
**Tags:** observables\
**Created:** [November 24, 2022, 12:19pm UTC](https://forum.babylonjs.com/t/observable-hasobservers-is-still-true-after-removing-all-the-observers/35987 "2022-11-24T12:19:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sharp](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sharp/32/1325_2.png) [@sharp](https://forum.babylonjs.com/u/sharp)\
**Post date:** [November 24, 2022, 12:19pm UTC](https://forum.babylonjs.com/t/observable-hasobservers-is-still-true-after-removing-all-the-observers/35987/1 "2022-11-24T12:19:31Z")

</div>

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

![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/6/a/6a4f04c18c29d2744104ef29f800bf10369fcae2.png)

To reproduce :

> **[Babylon.js Playground](https://playground.babylonjs.com/#FZ8959%238)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

Maybe i’m missing something ?

---

<div class="post-metadata">

**Author:** ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)\
**Post date:** [November 24, 2022, 12:25pm UTC](https://forum.babylonjs.com/t/observable-hasobservers-is-still-true-after-removing-all-the-observers/35987/2 "2022-11-24T12:25:50Z")

</div>

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)](https://playground.babylonjs.com/#FZ8959#9)

---

<div class="post-metadata">

**Author:** ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)\
**Post date:** [November 24, 2022, 12:27pm UTC](https://forum.babylonjs.com/t/observable-hasobservers-is-still-true-after-removing-all-the-observers/35987/3 "2022-11-24T12:27:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![sharp](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sharp/32/1325_2.png) [@sharp](https://forum.babylonjs.com/u/sharp)\
**Post date:** [November 24, 2022, 12:27pm UTC](https://forum.babylonjs.com/t/observable-hasobservers-is-still-true-after-removing-all-the-observers/35987/4 "2022-11-24T12:27:40Z")

</div>

Thank you @RaananW !

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [November 24, 2022, 2:50pm UTC](https://forum.babylonjs.com/t/observable-hasobservers-is-still-true-after-removing-all-the-observers/35987/5 "2022-11-24T14:50:27Z")

</div>

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:

> <https://github.com/BabylonJS/Babylon.js/pull/13283>
>
> See https://forum.babylonjs.com/t/observable-hasobservers-is-still-true-after-re…moving-all-the-observers/35987
