CONTEXT
Im makes a call, which if successful, changes the boolean value from false to true. Then, outside this call, I check to see if this is a boolean, and if so, I go to another page.
PROBLEM
Console logs indicate that the if statement, which checks the boolean, is executed before the calls have time to change the boolean. I understand that this is due to asynchrony, but I'm not sure what the correct design template will be for this. Here is a snippet:
var eventUpdated = false;
Meteor.call('updateEvent', eventId, eventParams, function(error, result){
if(error){
toastr.error(error.reason)
} else {
var venueId = result;
toastr.success('Event Info Updated');
eventUpdated = true;
console.log(eventUpdated)
}
});
console.log(eventUpdated)
if (eventUpdated) {
Router.go('/get-started/confirmation');
}
POSSIBLE SOLUTIONS
, , if , . Googling, , , , .