0
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;
// })
}
}
}
在上面的例子中改變從漁獲的值改變從try catch塊可觀察到的和最後塊提供了一個錯誤或警告不變失敗嚴格模式。什麼是正確的方法?不能在mobx嚴格模式