You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
That's a really good idea.
Note that I'm hoping to change the API in the months ahead, but for now, you write a mutation handler like this:
updateUserProfile(optimisticVariables, queryResponse, currentResponse) {
if (optimisticVariables) {
Object.assign(currentResponse.user, optimisticVariables.updatedProfile);
} else if (queryResponse) {
Object.assign(currentResponse.user, queryResponse);
}
return currentResponse;
},
This function runs twice. Once with optimisticVariables and again with a queryResponse (what comes back from the server). So, if you want to do something optimistically, you just check for optimisticVariables & mutate the object however you like. Those mutations get back propagated to the normalized state. Still not sure I love mutating it, but it's SO much easier than imperatively creating an object inside an object inside an array inside an object....
Can add example of Cashay+Optimistic UI for Recipe
The text was updated successfully, but these errors were encountered: