Top Banner
Write Once, Run Everywhere Mike North Mobile+Web Devcon 2015 @MichaelLNorth github.com/truenorth
48
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Write Once, Run Everywhere

Write Once, Run Everywhere

Mike North Mobile+Web Devcon 2015

@MichaelLNorth github.com/truenorth

Page 2: Write Once, Run Everywhere

@MichaelLNorth

Hi

Page 3: Write Once, Run Everywhere

@MichaelLNorth

Write once, run everywhere

Apache Cordova

Media Queries

Small

Medium

Large

Any

@MichaelLNorth

NW.js

Page 4: Write Once, Run Everywhere

@MichaelLNorth

//TODO

The state of HTML5

Case Study

Cross-Device Tech

Ember.js & Friends

Page 5: Write Once, Run Everywhere

@MichaelLNorth

Great places to startThe state of HTML5

2007 2008

HTML5 Mobile Beginnings

2009-2010

Page 6: Write Once, Run Everywhere

@MichaelLNorth

Great places to startThe state of HTML5

2012

Page 7: Write Once, Run Everywhere

@MichaelLNorth

Great places to startThe state of HTML5

Common opinion of hybrid apps

“Hybrid app performance sucks, so build native or go home” — Mark Z.

And now many businesses are asking“Do we have the $$$$$ required to build and

maintain several native apps, or should we neglect mobile?”

Page 8: Write Once, Run Everywhere

@MichaelLNorth

Great places to startThe state of HTML5

It’s time to reconsider

Newest iPhone Now

Newest iPhone 2012

iPhone 6

iPhone 4s

1612

215

2015

7.5X

Page 9: Write Once, Run Everywhere

@MichaelLNorth

Great places to startThe state of HTML5

Page 10: Write Once, Run Everywhere

@MichaelLNorth

Great places to startThe state of HTML5

Page 11: Write Once, Run Everywhere

@MichaelLNorth

Great places to startThe state of HTML5

Page 12: Write Once, Run Everywhere

@MichaelLNorth

Great places to startThe state of HTML5

Benefits of the hybrid app approach

• Web developers know the drill already • Functionality is not all that limited • Core “modern web” concepts are still valuable• URLs • HTTP

• Layout • Style

Page 13: Write Once, Run Everywhere

@MichaelLNorth

Great places to startThe state of HTML5

Shelf life of the web > Shelf life of native

Page 14: Write Once, Run Everywhere

@MichaelLNorth

Great places to startThe state of HTML5

Use cases we’ll focus on

• Menus • 2D views • CRUD • Notifications,

etc…

Page 15: Write Once, Run Everywhere

@MichaelLNorth

//TODO

The state of HTML5

Case Study

Cross-Device Tech

Ember.js and friends

Page 16: Write Once, Run Everywhere

@MichaelLNorth

Great places to startCross-Device Tech

NW.js

Page 17: Write Once, Run Everywhere

@MichaelLNorth

Great places to startCross-Device Tech

WebView Native App

Application API

XHR

XHR

WebView Method

Your App

Page 18: Write Once, Run Everywhere

@MichaelLNorth

Great places to startCross-Device Tech

image source: http://www.slideshare.net/hakimrie/phonegapcordova-vs-native-application

Page 19: Write Once, Run Everywhere

@MichaelLNorth

Great places to startCross-Device TechNW.js

image source: http://www.slideshare.net/Products123/nwjs-essentials-sample-chapter

Page 20: Write Once, Run Everywhere

@MichaelLNorth

Great places to startCross-Device Tech

These are very similar abstractionsOS

HTML/JS/CSS “Web App”

“Native” part of your app

JS API to invoke native functionality

Page 21: Write Once, Run Everywhere

@MichaelLNorth

Great places to startCross-Device Tech

Page 22: Write Once, Run Everywhere

@MichaelLNorth

Great places to startCross-Device Tech

#PROTIP - Facade Design Pattern

function sendNotification(title, message, icon)

Desktop Native

Mobile Native

Default

node-growl OS X notification

navigator.notification.alert()

show in-app notification

Page 23: Write Once, Run Everywhere

@MichaelLNorth

//TODO

The state of HTML5

Case Study

Cross-Device Tech

Ember.js and friends

Page 24: Write Once, Run Everywhere

@MichaelLNorth

Great places to startEmber.js and friends

What’s all about?

• Data binding • Convention over

configuration • Productivity-focused • Started as a fork of • Lots of great

companies use it

Page 25: Write Once, Run Everywhere

@MichaelLNorth

Great places to startEmber.js and friends

What do people love about ?

• Solid conventions • Abstractions that scale • Addresses the “whole problem” • Steers you toward consistent architecture • Core team

• All must work on their own apps • Work closely with TC39, WHATWG

Page 26: Write Once, Run Everywhere

@MichaelLNorth

Great places to startEmber.js and friends

What do people love about ?

• Opinionated, and many of the opinions are worth considering

Page 27: Write Once, Run Everywhere

@MichaelLNorth

Great places to startEmber.js and friends

$  ember-­‐cli

Page 28: Write Once, Run Everywhere

@MichaelLNorth

Great places to startEmber.js and friends

Ember-cli: what can it do?

• Dependency management and setup • Code generation • Asset pipeline • Development web server • Mock http endpoints • API proxy • And more…

Page 29: Write Once, Run Everywhere

@MichaelLNorth

Great places to startEmber.js and friends

Ember addons

• As easy to build as an app • Written in ES2015 • Pulled in as NPM dependencies • Can do lots of stuff to consuming app

• Make new ember objects available • Add preprocessors • Add new commands to ember-cli

Page 30: Write Once, Run Everywhere

@MichaelLNorth

Great places to startEmber.js and friends

Ember addons

http://emberaddons.com

Page 31: Write Once, Run Everywhere

@MichaelLNorth

Great places to startEmber.js and friends

Why does this matter for this discussion?

• Capable framework, suitable for complexity • Long shelf life • Easy to implement and set up tooling • Addons are ready and waiting for us!

Page 32: Write Once, Run Everywhere

@MichaelLNorth

//TODO

The state of HTML5

Case Study

Cross-Device Tech

Ember.js and friends

Page 33: Write Once, Run Everywhere

@MichaelLNorth

Great places to startCase Study

Page 34: Write Once, Run Everywhere

@MichaelLNorth

Great places to startCase Study

Start with URLs

/ /orgsor list of Github orgs

/org/jquery info about the jQuery org

/org/jquery/repos list of repos in the jQuery org

/org/jquery/repo/esprima info about esprima

Page 35: Write Once, Run Everywhere

@MichaelLNorth

Great places to startCase Study

Start with URLs/

/orgs

/org/jquery

/org/jquery/repos

/org/jquery/repo/esprima

index

orgs

org

org.repos

org.repo

Page 36: Write Once, Run Everywhere

@MichaelLNorth

Great places to startCase Study

Start with URLs

Page 37: Write Once, Run Everywhere

@MichaelLNorth

Great places to startCase Study

Add some models

REPOname url stargazers watchers issues

ORGname avatar_url description url

/org/jqueryorg.show

a.g.c/orgs/jquery

a.g.c/repos/jquery/esprima

/org/jquery/repo/esprimaorg.show.repo.show

Page 38: Write Once, Run Everywhere

@MichaelLNorth

Great places to startCase Study

Add some models

REPOname url stargazers watchers issues

ORGname avatar_url description url

/org/jqueryorg.show

a.g.c/orgs/jquery

a.g.c/repos/jquery/esprima

/org/jquery/repo/esprimaorg.show.repo.show

Page 39: Write Once, Run Everywhere

@MichaelLNorth

Great places to startCase Study

Let’s talk, API…

• Ember gives us two objects with very specific

roles • Adapter - Build URLs, send/rcv ajax request • Serializer - transform API Object / UI Object

Page 40: Write Once, Run Everywhere

@MichaelLNorth

Great places to startCase Study

Apply a responsive design

Page 41: Write Once, Run Everywhere

@MichaelLNorth

Great places to startCase Study

Bring in a material design framework

$ ember install ember-cli-materialize

Page 42: Write Once, Run Everywhere

@MichaelLNorth

Great places to startCase Study

Time for hybridifying

$ ember install ember-cli-cordova$ ember cordova:build$ ember serve

Page 43: Write Once, Run Everywhere

@MichaelLNorth

Great places to startCase Study

Page 44: Write Once, Run Everywhere

@MichaelLNorth

Great places to startCase Study

Desktopification

$ ember install ember-cli-cordova$ ember cordova:build$ ember serve

Page 45: Write Once, Run Everywhere

@MichaelLNorth

Great places to startCase Study

Desktopification

"window": { "title": "Write once, run everywhere", "toolbar": false, "min_width": 601, "min_height": 200, "width": 960, "height": 600 },

Page 46: Write Once, Run Everywhere

@MichaelLNorth

Great places to startCase Study

Page 47: Write Once, Run Everywhere

@MichaelLNorth

//TODO

Style

Case Study

Computed Properties

Components

Page 48: Write Once, Run Everywhere

@MichaelLNorth

@MichaelLNorth