# Force observable to populate change event

**URL:** <https://discourse.aurelia.io/t/force-observable-to-populate-change-event/1522>\
**Category:** Help Requests\
**Created:** [August 15, 2018, 7:53am UTC](https://discourse.aurelia.io/t/force-observable-to-populate-change-event/1522 "2018-08-15T07:53:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![indiwine](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/indiwine/32/1042_2.png) [@indiwine](https://discourse.aurelia.io/u/indiwine)\
**Post date:** [August 15, 2018, 7:53am UTC](https://discourse.aurelia.io/t/force-observable-to-populate-change-event/1522/1 "2018-08-15T07:53:21Z")

</div>

Hello.

I am still new to Aurelia. Maybe its a bit stupid question, but googling it does not really helped.  
So the question is sounds like this: Does aurelia binding engine have something similar to `valueHasMutated` method from knockout library?

For those who did not familiar with knockout: this method force observable and all its bindings and depencies to update while the observable`s value itself does not really changed.

In some cases (which are exceptional) such method becomes very handy.

Thanks for your answers.

---

<div class="post-metadata">

**Author:** ![huochunpeng](https://avatars.discourse-cdn.com/v4/letter/h/49beb7/32.png) [@huochunpeng](https://discourse.aurelia.io/u/huochunpeng)\
**Post date:** [August 15, 2018, 9:54am UTC](https://discourse.aurelia.io/t/force-observable-to-populate-change-event/1522/2 "2018-08-15T09:54:16Z")

</div>

Here is valueHasMutated method 🙂

```auto
valueHasMutated() {
  const old = this.value;
  this.value = !old;
  this.value = old;
}

```

---

<div class="post-metadata">

**Author:** ![indiwine](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/indiwine/32/1042_2.png) [@indiwine](https://discourse.aurelia.io/u/indiwine)\
**Post date:** [August 15, 2018, 10:19am UTC](https://discourse.aurelia.io/t/force-observable-to-populate-change-event/1522/3 "2018-08-15T10:19:07Z")

</div>

Yeah, but not quite 😉

Acctulay such method will trigger update dependencies twice:

1. first time when you type cast`this.value` to boolean
2. second time when you writing back original value.

This cusses two issues:

1. Unnecessary observable update
2. While `this.value` can be basically anything - casting it to boolean may cause unexpected behavior in views, subscriptions and so on.

---

<div class="post-metadata">

**Author:** ![huochunpeng](https://avatars.discourse-cdn.com/v4/letter/h/49beb7/32.png) [@huochunpeng](https://discourse.aurelia.io/u/huochunpeng)\
**Post date:** [August 15, 2018, 10:38am UTC](https://discourse.aurelia.io/t/force-observable-to-populate-change-event/1522/4 "2018-08-15T10:38:54Z")

</div>

Actually only one update, aurelia-binding is smart enough to merge them.

Furthermore, because the intermediate change is thrown away by aurelia-binding, it will rarely have surprising side effects due to boolean type.

---

<div class="post-metadata">

**Author:** ![indiwine](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/indiwine/32/1042_2.png) [@indiwine](https://discourse.aurelia.io/u/indiwine)\
**Post date:** [August 15, 2018, 12:15pm UTC](https://discourse.aurelia.io/t/force-observable-to-populate-change-event/1522/5 "2018-08-15T12:15:19Z")

</div>

Just tested your solution - amazing, but it works 🤔
