4 ms·
It's a hard problem. Offline means you're dealing with conflict detection, resolution, and caching strategies. Do you do multi-master? Have a single remote mas
by LAC-Tech 4y ago
It's a hard problem.
Offline means you're dealing with conflict detection, resolution, and caching strategies. Do you do multi-master? Have a single remote master but cache commands as a fallback? How do you test your solution?
And if you're dealing with the web, then you have to deal with IndexedDB which can sometimes be nuked by the browser, or have show stopping bugs (looking at you safari). There's also limited capacity compared to severside. Even if you use a library, under the hood they all use IndexedDB - there is no getting away from its limitations.
If anyone's interested in this stuff, I'd love to chat. I'm between contracts and trying to make an old app of mine work offline, lots of fun but also challenging.
- z3t4 4y agoA naive approach is to have a integer named "version" and a bool named "synced" beside each post/record/row. Then increment version and set synced=false when updating, and synced=true when synced. Or make the data/state immutable and just have the "synced" variable. A more complicated approach is to have transform operations for state changes, with a version variable, then the version variable is incremented on on a central server each change and decide in which order the transform operations should be applied.
- withinboredom 4y agoThat only works until the user has TWO offline devices and both making conflicting changes. A better solution would be to use something like Simperium (https://simperium.com/ https://simperium.com/). Disclosure: I work for Automattic.
- tharkun__ 4y agoNothing against you personally. I just would like to point out this awesome display of jumping into specific solutioning and show of technical prowess instead of staying on the abstract level of the parent and discussing the pros and cons and challenges of offline operation. None of the approaches you are talking about here are new. There are many ways to implement this. The parent knows this and simply abstractly said you need to "do conflict detection". And yes that is an issue. A solvable one which has implications though and the level of challenge depends on the domain and the number of operations (potentially dependent on each other operations) that you made while offline. In your domain, do multiple users usually edit the same 'thing' simultaneously or at least with a frequency higher than the amount of time you are offline? If so you have a challenge on your hand. A simple example of this is something we all do a lot. Coding. If you use say git and work offline 8h a day and push at the end of the day and you 10 other developers working on the same code base and your code and your work is structured in a way where all of you need to make changes to the same part of the code base you are going to be in a world of hurt of solving conflicts. Luckily code structure and work breakdown can be done in a way where you will only have minimal conflicts. Git also chose a specific resolution strategy: last one to the table has to deal with conflict resolution. Depending on your domain and how many dependent and complicated operations you allowed the user to make this can be really frustrating for users and impossible to resolve in an automated way. Of course simply providing an offline mode for your email program in a mailbox only you have access to is a much simpler domain with easily automatable resolution strategies that are easy for users to understand as well.
- More-nitors 4y ago> Offline means you're dealing with conflict detection, resolution, and caching strategies users of google maps / apple TV don't have to send 'write' operations except for a few features (set-favorite, etc)
- ev1 4y agoone could argue that users of google maps don't have to send 'write' operations at all to save favourites locally, but if you don't allow location history and GPS you barely get autocomplete and can't even keep a local list :)
- grayclhn 4y agoRead-only offline is not a hard problem. Regardless, lots of things are hard problems _the first time it’s solved_ but become easy problems with the right tools and design.