class Someclass {
@observable waiting = false;
@observable error = null;
@action.bound
async authenticate({login, password}) {
try {
this.waiting = true;
const res = await myService.authenticate(login, password);
} catch (error) {
this.error = error; // Gives an error: Invariant Failed
} finally {
this.waiting = false; // Gives an error: Invariant Failed
// I've tried doing this too
// action(() => {
// this.waiting = false;
// })
}
}
}
In above example altering values from catch and finally block gives an error or warning Invariant Failed with strict mode. What is the correct way ?
Inside of
async
function we must wrap a function insiderunInAction
utility method for mutating@observable
instrict
mode. Example.View this related issue on github