rewrite the watcher to only watch the remainingFunds object

This commit is contained in:
Andreas Zweili 2021-09-04 14:13:53 +02:00
parent 2a9a6a8907
commit 4576b66f67
1 changed files with 7 additions and 4 deletions

View File

@ -40,11 +40,14 @@ export default {
data.currentExpenses += enteredExpense.value; data.currentExpenses += enteredExpense.value;
} }
watch(data, function(_, newValue) { watch(
if (newValue.remainingFunds < 0) { () => data.remainingFunds,
alert('You are broke!'); function(_, newValue) {
if (newValue < 0) {
alert('You are broke!');
}
} }
}); );
return { return {
data, data,