rewrite the watcher to only watch the remainingFunds object
This commit is contained in:
parent
2a9a6a8907
commit
4576b66f67
|
@ -40,11 +40,14 @@ export default {
|
|||
data.currentExpenses += enteredExpense.value;
|
||||
}
|
||||
|
||||
watch(data, function(_, newValue) {
|
||||
if (newValue.remainingFunds < 0) {
|
||||
alert('You are broke!');
|
||||
watch(
|
||||
() => data.remainingFunds,
|
||||
function(_, newValue) {
|
||||
if (newValue < 0) {
|
||||
alert('You are broke!');
|
||||
}
|
||||
}
|
||||
});
|
||||
);
|
||||
|
||||
return {
|
||||
data,
|
||||
|
|
Reference in New Issue