Morgan C. Benton
Associate Professor, ISAT, James Madison University
Valley Tech Con 2019
WE CAN’T KEEP BUILDING APPS WITH THE DESKTOP MINDSET OF PERMANENT, FAST CONNECTIVITY, WHERE A TEMPORARY DISCONNECTION OR SLOW SERVICE IS REGARDED AS A PROBLEM AND COMMUNICATED AS AN ERROR.
--Alex Feyerke, "Say Hello to Offline First", November 2013
* One database per customer!?!?
Snapshot distributes data exactly as it appears at a specific moment in time and does not monitor for updates to the data. When synchronization occurs, the entire snapshot is generated and sent to client service.
Good when:
Examples: product catalog, speakers at a conference
Realtime typically starts with a snapshot of the remote database data. As soon as the initial snapshot is taken, subsequent data changes made at the remote are delivered to the client as they occur (in near real time). The data changes are applied at the client in the same order as they occurred at the remote.
Good when:
Examples: stock ticker, live sporting events
In "normal" realtime, data originating on a client must be processed on the remote API before being replicated to the local database. "Optimistic" mutation modifies the local database before remote processing happens and maybe changes it later, if necessary.
Good when:
Examples: chat or text messaging
The data is unique to the user, and (usually) not changeable by the remote. Local mutations are queued until the next time the client is connected. Own-data queues every change and processes them in order on the remote. Own-net only queues the net change to a record, and only the net changes are sent to the remote.
Good when:
Examples: user profiles or personal productivity apps
The data is owned by multiple users, and conflicts must be resolved by the remote. Each mutation sent to the remote must contain a "before and after" so that if multiple clients ask to mutate the same records at about the same time, some conflict resolution strategy can be employed. With sync-data each queue entry contains original plus >=1 ordered mutations. With sync-net, each queue entry contains original plus the net change at the time the mutation request is sent to the remote.
Good when:
Examples: multi-user shared document editing
All mutations of all records are stored indefinitely or for a "long time" so that it is possible to "time travel" to see the state of a record at any given point in time. Since this will likely require a large amount of storage, it may only be appropriate when the clients have a great deal of storage capacity. Alternatively, once the queue is stored on the remote, the local replicant may only need to store pointers to each of the mutations.
Good when:
Examples: git repositories, undo queues for documents
The Valley Tech Con 2019 app allows users to view the conference schedule, details about speakers, talks, and sponsors, as well as rating the events and tweeting about them.
Tech Stack:
API--FeathersJS
App--VueJS + Vuetify
People spend HUGE amounts of time on their phones, but...
Can apps be powerful? Yes. But you have to be very careful and very strategic about how they're used. Paying attention to user experience, including offline utility, is part of that.
morgan.benton@gmail.com
https://morphatic.com
https://github.com/morphatic