<div id="output" />
const log = (msg) => document.getElementById('output').innerHTML += `${msg}<br/>`;
const state = Vue.observable({ val: true });
const instance = new Vue();
instance.$watch(
() => {
log('record synchronous');
return state.val;
},
() => log('trigger synchronous')
);
instance.$watch(
async () => {
await Promise.resolve();
log('record asynchronous');
return state.val;
},
() => log('trigger asynchronous')
);
Promise.resolve().then(() => {
log('change state');
state.val = false;
});
This Pen doesn't use any external CSS resources.