50
©2015 Couchbase Inc. 1 Nic Raboy, Developer Advocate at Couchbase Developing For Offline First Mobile Experiences

Developing for Offline First Mobile Experiences

Embed Size (px)

Citation preview

©2015 Couchbase Inc. 1

Nic Raboy, Developer Advocate at Couchbase

Developing For Offline First Mobile Experiences

©2015 Couchbase Inc. 2

About Me

Nic RaboyDeveloper Advocate at [email protected]@nraboy (Twitter)

©2015 Couchbase Inc. 3

The Plan

Where are things headed The business problem Couchbase Mobile Example native code Example hybrid code

©2015 Couchbase Inc. 4

Current State

©2015 Couchbase Inc. 5

Trends

©2015 Couchbase Inc. 6

RDBMS

©2015 Couchbase Inc. 7

NoSQL

What is the business problem?

Today’s Mobile Apps

9

Try again later.

No Internet

please wait…

©2015 Couchbase Inc. 10

How Does This Affect What People Think?

Doesn’t work a lot of the time and when it does it’s slow.

©2015 Couchbase Inc. 11

How Does This Affect App Uninstall Rates?

0%

20%

40%

60%

80%

100%

FreezingCrashingSlow Responsiveness

Unin

stal

l Rat

e

Source: uSamp

Data Location is the Problem

12

Local Data + Sync is the Solution

13

©2015 Couchbase Inc. 14

What Does This Mean For Your Apps

Always work both online & offlineAlways be blazing fast

Built with orders of magnitude less codeUsers will absolutely love your apps

What is Couchbase Mobile?

Couchbase Lite Sync Gateway

©2015 Couchbase Inc. 17

Couchbase Lite

• NoSQL Mobile Database• Document Oriented & Schema-Less• Small Footprint• Runs In-Process

©2015 Couchbase Inc. 18

Couchbase Sync Gateway

• Data Replication Between Server & Device

• Data Orchestration• Authentication & Authorization

©2015 Couchbase Inc. 19

Replication

Is asynchronous Can be continuous or one-shot Sends JSON over HTTP Handles network hiccups Network timeouts

©2015 Couchbase Inc. 20

Channels

Sports San Francisco

Nature

Admin

21

©2015 Couchbase Inc. 22

Available SDKs & Frameworks

©2015 Couchbase Inc. 23

Couchbase Mobile Summary

Offline first approach NoSQL document database Works with Couchbase Server Available for many platforms and frameworks

Couchbase Lite for Native Android & iOS

©2015 Couchbase Inc. 25

Creating a Database

©2015 Couchbase Inc. 26

Inserting a Document

©2015 Couchbase Inc. 27

Couchbase Lite Views

©2015 Couchbase Inc. 28

Map / Reduce Views

Concept from functional program, via Google App-defined map function operates on

documents Function output generates an index ordered by

key Index rows can be aggregated via a reduce

function Index is queried by a key or key range

©2015 Couchbase Inc. 29

Replication With Sync Gateway

©2015 Couchbase Inc. 30

Listen For Changes

©2015 Couchbase Inc. 31

Other Ways To Listen

DatabaseChanged: Any document updated DocumentChanged: A specific document

updated LiveQuery: Change in query result set

©2015 Couchbase Inc. 32

Couchbase Lite for iOS Special Note

iOS SDK works for OS X desktop applications

Couchbase Cordova Plugin

©2015 Couchbase Inc. 34

Couchbase Cordova Plugin

Compatible with Android and iOS Access Couchbase Lite via RESTful APIs Easily integrate with Ionic Framework and

PhoneGap through the ng-couchbase-lite wrapper

©2015 Couchbase Inc. 35

Creating a Database

©2015 Couchbase Inc. 36

Inserting Documents

©2015 Couchbase Inc. 37

Couchbase Lite Views

©2015 Couchbase Inc. 38

Querying Couchbase Views

©2015 Couchbase Inc. 39

Replication With Sync Gateway

©2015 Couchbase Inc. 40

Listen for Changes

Couchbase Sync Gateway

©2015 Couchbase Inc. 42

Basic Sync Gateway Configuration

Creating a Native Android ToDo List

©2015 Couchbase Inc. 44

Couchbase Mobile ToDo List Application

©2015 Couchbase Inc. 45

Code Walkthrough! Creating the UI Initializing the Android ListView Designing the Android ListView Creating a database and replicating with the

server Listening for database changes Adding data to the database Removing data from the database Cleaning up when terminating the application

Demo Time!

©2015 Couchbase Inc. 47

Couchbase Labs on GitHub

https://github.com/couchbaselabs/todolite-androidhttps://github.com/couchbaselabs/todolite-ioshttps://github.com/couchbaselabs/todolite-ionic

Questions?

©2014 Couchbase, Inc.

©2015 Couchbase Inc. 49

We’re Hiring!http://www.couchbase.com/careers

©2015 Couchbase Inc. 50

Thank You!

Nic [email protected]@nraboy (Twitter)