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.
Here is valueHasMutated method
valueHasMutated() {
const old = this.value;
this.value = !old;
this.value = old;
}
Yeah, but not quite
Acctulay such method will trigger update dependencies twice:
- first time when you type cast
this.value
to boolean
- second time when you writing back original value.
This cusses two issues:
- Unnecessary observable update
- While
this.value
can be basically anything - casting it to boolean may cause unexpected behavior in views, subscriptions and so on.
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.
Just tested your solution - amazing, but it works