Even though in the previous step we're making persistent changes in the remote database, we still aren't serving that data in the pull endpoint (it's still static 🤣).
The reason we don't see the changes disappearing from the source browser is because Replicache is doing its job and holding onto speculative changes until they are confirmed by the server!
Let's fix that now. We'll also use the
cookie field to return only changed messages.
Replace the contents of
pages/api/replicache-pull.js with this code:
Voila. We're now round-tripping browsers and devices!
Also notice that if we go offline for awhile, make some changes, then come back online, the mutations get sent when possible.
We don't have any conflicts in this simple data model, but Replicache makes it easy to reason about most conflicts. See the Design Doc for more details.
The only thing left is to make it live — we obviously don't want the user to have to manually refresh to get new data 🙄.