I have some global vars initialized in a script tag in HTML:
<script>
count = 0;
window.count2 = 0;
var count3 = 0;
</script>
In app.js
, I subscribe to observe their changes:
let subscription = bindingEngine.propertyObserver(window, 'count')
.subscribe((newValue, oldValue) => console.log('Global count: ', newValue, oldValue));
let subscription2 = bindingEngine.propertyObserver(window, 'count2')
.subscribe((newValue, oldValue) => console.log('window.count2: ', newValue, oldValue));
let subscription3 = bindingEngine.propertyObserver(window, 'count3')
.subscribe((newValue, oldValue) => console.log('Global count3: ', newValue, oldValue));
Then I change the values like this:
change() {
count++;
count2++;
count3++;
}
only count
&& count2
are observerd in console:
Global count: 1 0
window.count2: 1 0
Here is GistRun
Question: why count3
cannot be observed? I thought 3 forms of initialization are equivalent.