0π
β
It turns out the computed ref has a .value
property which is the typed variable. I changed my code to the following to make it work:
const account = computed<AuthenticationAccount>(() => store.state.authentication.account);
watch(() => account.value, (newValue, oldValue) => {
if (oldValue.loading && !newValue.loading && !newValue.hasAccount) {
// no account so redirect to unauthenticated page
window.location.href = spaUrls.accessDenied;
}
});
As commented, I can also use
watch(account, (newValue, oldValue) => {
if (oldValue.loading && !newValue.loading && !newValue.hasAccount) {
// no account so redirect to unauthenticated page
window.location.href = spaUrls.accessDenied;
}
});
Source:stackexchange.com