Offline-First Apps with PouchDB and IBM Cloudant



Similar documents
Cloudant Querying Options

Developing multidevice-apps using Apache Cordova and HTML5. Guadalajara Java User Group Guillermo Muñoz Java Developer

Mobile apps development for Joomla

Smartphone Enterprise Application Integration

Lab - Building an Internet of Things Application Hands-On Lab

Reading Kindle titles on your PC or Mac

Overview of Databases On MacOS. Karl Kuehn Automation Engineer RethinkDB

AdRadionet to IBM Bluemix Connectivity Quickstart User Guide

Building Internet of Things Apps with Cloudant DBaaS. Andy Ellicott, Cloudant John David Chibuk, Kiwi Wearables

Retool your HTML/JavaScript to go Mobile

This is our best... YOUR best... Online Banking yet!

Medstar Health Dell Services

Gladinet Cloud Access Solution Simple, Secure Access to Online Storage

Building native mobile apps for Digital Factory

ios SDK possibilities & limitations

Saturday, 13 June CouchDB. Apache

Introduction to IBM Worklight Mobile Platform

Monitoring Agent for Microsoft Exchange Server Fix Pack 9. Reference IBM

RTMP Channel Server I6NET Solutions and Technologies

Drupal Performance Tuning

SYST35300 Hybrid Mobile Application Development

The full setup includes the server itself, the server control panel, Firebird Database Server, and three sample applications with source code.

Testing & Assuring Mobile End User Experience Before Production. Neotys

E21 Mobile Users Guide

How To Synchronize With A Cwr Mobile Crm 2011 Data Management System

Aspera Connect User Guide

System Requirements for Microsoft Dynamics NAV 2016

Cloud Powered Mobile Apps with Azure

owncloud Architecture Overview

Mobile Test Strategy. Shankar Garg. Senior Consultant - Testing

Technical Overview: Anatomy of the Cloudant DBaaS

Certified Apache CouchDB Professional VS-1045

OneDrive for Business. (formerly SkyDrive Pro) An Introductory Briefing

SAP Mobile Platform Intro

Developing Cross-platform Mobile and Web Apps

DevOps Best Practices for Mobile Apps. Sanjeev Sharma IBM Software Group

User Guide FOR TOSHIBA STORAGE PLACE

VMware Identity Manager Administration

System Requirements for Microsoft Dynamics NAV 2016

Qsync Install Qsync utility Login the NAS The address is :8080 bfsteelinc.info:8080

Pure1 Manage User Guide

50 shades of Siebel mobile

Akin Gump Strauss Hauer & Feld LLP Remote Access Resources

This document is provided to you by ABC E BUSINESS, Microsoft Dynamics Preferred partner. System Requirements NAV 2016

Camilyo APS package by Techno Mango Service Provide Deployment Guide Version 1.0

System Requirements for Microsoft Dynamics NAV 2016

Telecommunications Mobility Options

Apache Milagro (incubating) An Introduction ApacheCon North America

Aspera Connect User Guide

BERLIN. 2015, Amazon Web Services, Inc. or its affiliates. All rights reserved

Load and Performance Load Testing. RadView Software October

Best practices building multi-platform apps. John Hasthorpe & Josh Venman

Building resilient infrastructure with CouchDB

Spontania User Setup Guide

System Requirements. Microsoft Dynamics NAV 2016

Connection. to SECON-Server

Why NoSQL? Your database options in the new non- relational world IBM Cloudant 1

HTML5 and Device APIs for Automotive: Is it time to power Infotainment and Car Portal Applications with Web Technologies?

Dell OpenManage Mobile Version 1.4 User s Guide (Android)

Enable Your Automated Web App Testing by WebDriver. Yugang Fan Intel

HTML5 Offline Data. INF5750/ Lecture 6 (Part II)

Building a BI Solution in the Cloud

Office 365 SharePoint Online

Mobile Performance Testing Approaches and Challenges

OneDrive for Business

slides at goo.gl/kifue

Creating Enterprise Mobile Apps with Red Hat

Download and Launch Instructions for WLC Client App Program

Frequently Asked Questions

System requirements. for Installation of LANDESK Service Desk Clarita-Bernhard-Str. 25 D Muenchen. Magelan GmbH

Web Browser. Fetches/displays documents from web servers. Mosaic 1993

Connections Mobile 4.0 Update Open Mic October 23, 2012

Web-based Hybrid Mobile Apps: State of the Practice and Research Opportunities

Getting Started with VMware Horizon View (Remote Desktop Access)

Real-time Data Analytics mit Elasticsearch. Bernhard Pflugfelder inovex GmbH

Hadoop. MPDL-Frühstück 9. Dezember 2013 MPDL INTERN

CRM 2016 INTEGRATIONS

Tracking a Soccer Game with Big Data

Single Sign-On Portal User Reference (Okta Cloud SSO)

Course Summary. Prerequisites

Download the Launcher File on Windows

Integrating Mobile apps with your Enterprise

Dropbox for Business. Secure file sharing, collaboration and cloud storage. G-Cloud Service Description

Mobile Devices and API. Alex Solonenko, Director of SD Pascal Laumet, Director of Product Development

Smartphone Application Development using HTML5-based Cross- Platform Framework

Building Cloud-powered Mobile Apps

Pwning Intranets with HTML5

SHC Client Remote Access User Guide for Citrix & F5 VPN Edge Client

Wireless Presentation Gateway. User Guide

Introduction to Mobile Performance Testing

IBM Worklight Mobile Application development and Management IBM Corporation

Using Apache Derby in the real world

Actualtests.C questions

Enhance Your SAP Portal Experience Using SAP Mobile Documents. Matt Carrier, SAP SESSION CODE: PO358

SalesPad Mobile Usage Guide. Contents. A software product created by SalesPad Solutions Copyright

Transcription:

Offline-First Apps with PouchDB and IBM Cloudant Cloud Computing Expo Bradley Holt, Developer Advocate Wednesday, June 8, 2016 @BradleyHolt

@BradleyHolt

IBM Cloud Data Services Open for Data A comprehensive por.olio of open source data services

Why offline first?

Mobile First Design for the smallest device first and then apply progressive enhancement techniques to take advantage of larger screen sizes when available

Offline First Design for offline usage first and then apply progressive enhancement techniques to take advantage of network connectivity when available

Ubiquitous Connectivity Why offline first in a world of ubiquitous connectivity?

The Eight Fallacies of Distributed Computing 1. The network is reliable 2. Latency is zero 3. Bandwidth is infinite 4. The network is secure 5. Topology doesn't change 6. There is one administrator 7. Transport cost is zero 8. The network is homogeneous @BradleyHolt

Mobile Backend What happens when your mobile backend service is unreachable?

Benefits of Offline First

Faster User Experience Better, faster user experience both offline and online

Works Offline Ability to disconnect and continue to work offline

Battery and Bandwidth Limited access to power and communications infrastructure in disaster scenarios

Offline-First Patterns and Anti-Patterns

Tools and Use Cases

CouchDB Replication Protocol CouchDB CouchDB Replication Protocol CouchDB Cloudant Sync PouchDB @BradleyHolt

@BradleyHolt

PouchDB Code Examples github.com/bradley-holt/offline-first

JSON Documents { } _id: "6EF9D2B0-13D3-1378-8D30-39E3CE0B36C2", _rev: "1-0b457efcf82fb29492ef927ba5b6ee15", type: "Feature", geometry: { type: "Point", coordinates: [ -71.1028, 42.3691 ] }, properties: { session_id: "3486b13f-7b8a-8a96-dfbf-9b82800e367f", timestamp: 1422928591717 } @BradleyHolt

Creating a PouchDB Database var db = new PouchDB("smart-meter"); @BradleyHolt

Creating a New Document var db = new PouchDB("smart-meter"); db.put({ _id: "2014-11-12T23:27:03.794Z", kilowatt_hours: 14 }).then(function() { console.log("document created"); }).catch(function(error) { console.log(error); }); @BradleyHolt

Updating a Document db.put({ _id: "2014-11-12T23:27:03.794Z", kilowatt_hours: 14 }).then(function(response) { return db.get(response.id); }).then(function(doc) { // Update the value for kilowatt hours doc.kilowatt_hours = 15; // Put the document back to the database return db.put(doc); }).catch(function(error) { console.log(error); }); @BradleyHolt

Querying a Database with alldocs db.bulkdocs([ {_id: "2014-11-12T23:27:03.794Z", kilowatt_hours: 14}, {_id: "2014-11-13T00:52:01.471Z", kilowatt_hours: 15}, {_id: "2014-11-13T01:39:28.911Z", kilowatt_hours: 16}, {_id: "2014-11-13T02:52:01.471Z", kilowatt_hours: 17} ]).then(function(result) { // Get all documents return db.alldocs({include_docs: true}); }).then(function(response) { console.log(response); }).catch(function(error) { console.log(error); }); @BradleyHolt

alldocs Options include_docs conflicts attachments startkey endkey inclusive_end (true by default) limit skip descending key keys @BradleyHolt

Querying a Database with Map/Reduce Most queries can be done with alldocs (in PouchDB) Map functions transform documents into indexes Reduce functions aggregate results of Map functions _sum _count _stats @BradleyHolt

Querying a Database with PouchDB Find Based on Cloudant Query (Mango) Declarative indexes MongoDB-style query language @BradleyHolt

PouchDB Data Storage Limits Firefox Chrome Opera 15+ Internet Exporer 10+ ios Safari Safari (desktop) Android PhoneGap / Cordova Data Storage Limit 50MB (more with user permission) calculated calculated 250MB (prompts user at 10 MB) 50MB (prompts user at 5MB and at increments) unlimited (prompts user at 5MB and at increments) calculated / 200MB unlimited Adapter IndexedDB IndexedDB / WebSQL IndexedDB / WebSQL IndexedDB WebSQL WebSQL IndexedDB / WebSQL SQLite @BradleyHolt

Replication

Apache CouchDB CouchDB is a document database featuring an HTTP API, JSON documents, and peer-to-peer replication @BradleyHolt

Creating a Remote PouchDB Database var remotedb = new PouchDB("https://bradley-holt.cloudant.com/smart-meter"); @BradleyHolt

Cross-Origin Resource Sharing (CORS) A security restriction implemented by browsers on cross-site HTTP requests @BradleyHolt

Bidirectional Replication @BradleyHolt

Bidirectional Replication db.sync(remotedb, { live: false, retry: false }).on("change", function(info) { // Replication has written a new document console.log(info); }).on("complete", function(info) { // Replication has complete or been cancelled console.log(info); }).on("error", function(error) { // Replication has stopped due to an unrecoverable failure console.log(error); }); @BradleyHolt

Live Replication @BradleyHolt

Live Replication var sync = db.sync(remotedb, { live: true, retry: true }).on("change", function(info) { // Replication has written a new document console.log(info); }).on("complete", function(info) { // Replication has complete or been cancelled console.log(info); }).on("error", function(error) { // Replication has stopped due to an unrecoverable failure console.log(error); }); @BradleyHolt

Filtered Replication @BradleyHolt

Filtered Replication db.replicate.to(remotedb, { filter: function(doc) { return doc._id >= "2014-11-13T00:00:00.000Z"; } }).on("change", function(info) { // Replication has written a new document console.log(info); }).on("complete", function(info) { // Replication has complete or been cancelled console.log(info); }); @BradleyHolt

One Database Per User userdb-c082f2 userdb-85bcfe userdb-a1ec1f userdb-d76846 userdb-905cec userdb-adc95b userdb-730bba erdb-da3d25 userdb-9b9aba userdb-c3d3e5 userdb-85a327 @BradleyHolt

Boilerplates & Tools Frontend Web Apps React Boilerplate with Service Workers <https://github.com/mbrio/react-boilerplate/tree/react-0.13-flummox-service> Backend Web Apps PouchDB npm Package <https://www.npmjs.com/package/pouchdb> PouchDB Server npm Package <https://www.npmjs.com/package/pouchdb-server> Mobile Apps PouchDB for Ionic Framework <https://github.com/nolanlawson/pouchdb-ionic> "Hello world" Cordova app with PouchDB <https://github.com/nolanlawson/pouchdb-cordova-hello-world> "Hello world" Cordova app with PouchDB, using the SQLite Plugin <https://github.com/nolanlawson/pouchdb-cordova-hello-world-with-sqlite-plugin> Cloudant FoodTracker (uses Cloudant Sync for ios) <https://github.com/ibm-cds-labs/cloudant-food-tracker> Desktop Apps PouchDB for Electron (formerly Atom Shell) <https://github.com/nolanlawson/pouchdb-electron> PouchDB for Chrome packaged apps <https://github.com/nolanlawson/pouchdb-chrome-app> "Hello world" Chrome app with PouchDB <https://github.com/nolanlawson/pouchdb-chrome-app-hello-world> PouchDB for NW.js (aka Node-Webkit) <https://github.com/nolanlawson/pouchdb-nw> Internet of Things (IoT) Apps Node-RED <http://nodered.org/> @BradleyHolt

Cloudant FoodTracker An offline-first demo app built with Swift and Cloudant Sync for ios

Offline Camp June 24 th - 26 th, Catskill Mountains

offlinefirst.org/camp

Image Credits A mockup of the golden Apple iphone 5S by Zach Vega, on Wikimedia Commons <https://commons.wikimedia.org/wiki/file:iphone_5s.png> Joan Touzet (@wohali), ASF Member, CouchDB PMC Member <https://twitter.com/wohali/status/595689720933445632> Device landscape by Jeremy Keith, on Flickr <https://flic.kr/p/anlchu> Cloud Formation Over the Adirondacks by Bradley Holt, on Twitter <https://twitter.com/bradleyholt/status/623030107679002624> Cell phone tower by Gary Lerude, on Flickr <https://flic.kr/p/crl7tn> Pneumatic Central by Sleestak, on Flickr <https://flic.kr/p/mrvrq> Colunas by Daniel Zanini H., on Flickr <https://flic.kr/p/5zwhwv> Speed DLR on Doklands by Umberto Rotundo, on Flickr <https://flic.kr/p/7gmcuo> Waterfall by Paulo Valdivieso, on Flickr <https://flic.kr/p/onkvrp> Wildfire by U.S. Fish and Wildlife Service Southeast Region, on Flickr <https://flic.kr/p/8zkwgd> Arduino Uno by Pete Prodoehl, on Flickr <https://flic.kr/p/a3ky7e> Mango with section on a white background by bangdoll, on Flickr <https://flic.kr/p/9cbp2h> Warning by Stefano Brivio, on Flickr <https://flic.kr/p/tubha> @BradleyHolt

Questions? @BradleyHolt