Testing models is straightforward. Especially because MST provides powerful tools to track exactly how your state changes over time. Track snapshots, action invocations or even patches to verify the correctness of your actions!
In this lesson you will learn:
getSnapshot
onSnapshot
onPatch
Can the model intercept changes as a way to play animations? When the animation completes, then apply the model changes. I tried something like this:
addMiddleware(myModel, (call, next) => { // setTimeout is to simulate an animation. setTimeout(()=>{ next(call) }, 2000) });
But an error of: Error: [mobx-state-tree] Neither the next() nor the abort() callback within the middleware for the action: