Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Indiana Jones and the Offline Apps - Droidcon E...

Indiana Jones and the Offline Apps - Droidcon Edition

Indiana Jones and the Offline Apps

Archaeology professor Indiana Jones, has been betrayed in its latest adventure.

Looking for the Grail he’s been led to believe that he lives on a connected world. However, when he is about to face the trials, he bitterly founds that he is unable because the data he needs is not available in the middle of the desert.

But then he hears of mythical legend of Offline First, and ancient magic that allowed developers to build apps impervious to connectivity errors.

Follow Dr. Jones in the thrilling quest to uncover the secrets and techniques that will allow him to build network independent apps!

Saúl Díaz

December 21, 2019
Tweet

More Decks by Saúl Díaz

Other Decks in Programming

Transcript

  1. 2

  2. 3

  3. 4

  4. 5

  5. “ Offline is not a set of techniques to make

    your app faster. It is a philosophy that drives how your product is experienced. 6
  6. 12

  7. A GREAT OFFLINE EXPERIENCE RECIPE ➢ Highly optimistical ➢ Low

    to no saliency ➢ Gracefully aware of errors 26
  8. 34

  9. SIT AND THINK ➢ Understand your platform ➢ Understand your

    feature ➢ Understand your limitations 35
  10. 37 CACHE DEV CLEAN ARCHITECTURE UPDATES FROM THE REAL WORLD

    USER WAITING TO PRESS “FOLLOW” BUTTON A THOUSAND TIMES A SECOND
  11. TRACKING MODIFICATIONS VIA METADATA 39 { "id": "sefford", "rev": "1a2b3c",

    "draft": "true", "deleted": "false", "data": "..." } ➢ Vector Clocks ➢ Lamport timestamps
  12. LOGIC DIFFERENTLY 40 class ChangeAvatarUseCase() { fun execute(userId: String, newAvatar:

    String, callback : () -> Unit) { api.changeUserId(userId, newAvatar) cache.saveUser(cache.getUser(userId) .copy(avatar = newAvatar)) callback(newAvatar) } } // On View fun onUpdateAvatarClicked() { changeAvatar.execute(currentUserId, newAvatar)) { avatar -> updateUI(avatar) } }
  13. LOGIC DIFFERENTLY 41 // On View fun onUpdateAvatarClicked() { changeAvatar.execute(currentUserId,

    newAvatar)) { avatar -> updateUI(avatar) } } class CommitAvatarChange() { fun execute(userId: String, newAvatar: String) { cache.saveUser(cache.getUser(userId) .copy(avatar = newAvatar)) } } class PushAvatarChange() { fun execute(userId: String, newAvatar: String) { api.changeUserId(userId, newAvatar) } }
  14. LOGIC DIFFERENTLY 42 // On View fun onUpdateAvatarClicked() { updateUI(avatar)

    changeAvatar.execute(currentUserId, newAvatar)) } class OfflineAvatarChange() { fun execute(userId: String, newAvatar: String) { commitAvatarChange.execute(userId, newAvatar) // Executes a Job when Network is available workerManager.enqueueAvatarChange(userId, newAvatar) } } class ClassicAvatarChange() { fun execute(userId: String, newAvatar: String) { commitAvatarChange.execute(userId, newAvatar) pushAvatarChange.execute(userId, newAvatar) callback(newAvatar) } }
  15. EFFICIENT PLACEHOLDER PRODUCTION 44 <!-- layouts.xml file --> <resources> <!--

    Random Grid Item --> <item name="item_grid_placeholder" type="layout">@layout/item_grid_base</item> <item name="item_grid_renderable" type="layout">@layout/item_grid_base</item> </resources> item_grid_base.xml User #1984 Likes Droidcon, Madrid & Cocido
  16. “ Conflicts are not an error condition, the are the

    result of your infrastructure allowing the same data set to be modified across disconnected systems. The introduction of such conflicts in such a topology is the expected behaviour and their programmatic resolution is a core piece of the application logic. 46 https://developer.ibm.com/dwblog/2015/cloudant-document-conflicts-two/
  17. OFFLINE TECHNOLOGIES 47 Web App Polymer App Toolbox Ionic Hoodie

    WorkManager SyncAdapters CouchDB Realm Firebase
  18. 48

  19. FINAL TIPS ➢ Offline can be implemented à la carte

    ➢ Introspection over the playing field is critical ➢ Strive to build apps that work like magic! 50
  20. CREDITS AND RESOURCES Special thanks to all the people who

    made and released these awesome resources for free: ➢ Offline first resource website ➢ Miguel Quiñones awesome presentation about offline ➢ Nice list of resources about offline topics ➢ What’s graceful degradation? ➢ Cesar Valiente’s Wunderlist Sync Architecture presentation ➢ Presentation template by SlidesCarnival ➢ Maps in slides from David Rumsey Map Collection 51
  21. 52