Hi,
I need to know the previous value for a document from mongo.
An autorun block is run every time the document is updated.
How can I know the previous value from an autorun dependency ?
Is the following scenario common? What is the common approach?
In angularJs, $watches are executed on a changed and let you know the previous value.
let previousGame = {};
this.autorun(() => {
let game = this.getGame();
if (!game) {
return;
}
// The above block is because game is null until subscription is ready
// Is there a more elegant way to avoid the above check?
//Exec some logic here
//More code
if (previousGame.player2 && !game.player2) {
//Player2 quit the game
}
previousGame = { ...game };
});