web∩アプリ

35
Web∩アプリ Mozilla Japan テクニカルマーケティング 清水智公 ([email protected]) Firefox Developers Conference 2014 in Kyoto 2014/04/19

Upload: noritada-shimizu

Post on 17-May-2015

3.058 views

Category:

Technology


0 download

DESCRIPTION

Firefox Developers Conference 2014 in Kyoto でお話ししたスライドです。

TRANSCRIPT

Page 1: Web∩アプリ

Web∩アプリ

Mozilla Japan テクニカルマーケティング 清水智公 ([email protected])

Firefox Developers Conference 2014 in Kyoto 2014/04/19

Page 2: Web∩アプリ

about:me

2

Page 3: Web∩アプリ

清水智公(しみずのりただ)

• Mozilla Japan テクニカルマーケティング

• 慶應義塾大学政策・メディア研究科非常勤

• @chikoski • https://slideshare.net/chikoski/

3

Page 4: Web∩アプリ

jQueryつかえるんですか?

4

Page 5: Web∩アプリ

スタブコードの生成

5

Page 6: Web∩アプリ

スタブコードの生成:Yeomanの場合

% npm install -g yo% npm install -g generator-firefoxos% mkdir myApp% cd myApp% yo firefoxos

6

Page 7: Web∩アプリ

スタブコードの生成:volojsの場合

% npm install -g volo% volo create myApp\ mozilla/motor-app-stab

7

http://volojs.org/

Page 8: Web∩アプリ

UIフレームワーク

8

Page 9: Web∩アプリ

jQuery Mobile

9

Page 10: Web∩アプリ

http://buildingfirefoxos.com/

10

Building Blocks

Page 11: Web∩アプリ

MVC / MVVMフレムワーク

11

Page 12: Web∩アプリ

Model-View-ViewModel

12

Page 13: Web∩アプリ

var DocumentRow = Backbone.View.extend({ tagName: "li", className: "document-row", events: { "click .icon": "open", "click .button.edit": "openEditDialog", "click .button.delete": "destroy" }, initialize: function() { this.listenTo(this.model, "change", this.render); }, render: function() { ... }});

13

Page 14: Web∩アプリ

Ember.js

App.ApplicationController = Ember.Controller.extend({ // the initial value of the `search` property search: '',! actions: { query: function() { // the current value of the text field var query = this.get('search'); this.transitionToRoute('search', { query: query }); } }});

14

Page 15: Web∩アプリ

データの永続化

15

Page 16: Web∩アプリ

localForage

var users = [

{id: 1, fullName: 'Matt'},

{id: 2, fullName: 'Bob'}

];

localForage.setItem('users', users, function(result) {

console.log(result);

});

16

https://github.com/mozilla/localForage

Page 17: Web∩アプリ

IndexedDB// IndexedDB.var db;var dbName = "dataspace"; var users = [ {id: 1, fullName: 'Matt'}, {id: 2, fullName: 'Bob'} ]; var request = indexedDB.open(dbName, 2); request.onerror = function(event) { // Handle errors.};request.onupgradeneeded = function(event) { db = event.target.result; var objectStore = db.createObjectStore("users", { keyPath: "id" });

objectStore.createIndex("fullName", "fullName", { unique: false }); objectStore.transaction.oncomplete = function(event) { var userObjectStore = db.transaction("users", "readwrite").objectStore("users"); }}; // Once the database is created, let's add our user to it... var transaction = db.transaction(["users"], "readwrite"); // Do something when all the data is added to the database.transaction.oncomplete = function(event) {

console.log("All done!");}; transaction.onerror = function(event) { // Don't forget to handle errors!}; var objectStore = transaction.objectStore("users"); for (var i in users) { var request = objectStore.add(users[i]); request.onsuccess = function(event) { // Contains our user info. console.log(event.target.result); };}

17

Page 18: Web∩アプリ

localForage:ドライバの設定

localforage.setDriver('localStorageWrapper');!

localforage.setDriver('localStorageWrapper').then(function() { alert(localforage.driver);});

18

Page 19: Web∩アプリ

カスタムコンポーネント

19

Page 20: Web∩アプリ

Brick:UIコンポーネント集

<x-calendar></x-calendar>

20

Page 21: Web∩アプリ

X-Tag:カスタムコンポーネントの定義

xtag.register('x-status-hud', { lifecycle: { created: function(){ } }, methods: { show: function (){ this.visible = true; }, hide: function (){ this.visible = false; } },}); // End tag declaration

21

Page 22: Web∩アプリ

jsファイルの依存性の解決

22

Page 23: Web∩アプリ

RequireJS

define(["jquery", "backbone"], function($, Backbone){ var model = Backbone.Model.exntend({ initialize: function(){ } }); return model;});

23

Page 24: Web∩アプリ

アプリ開発者の視点

24

Page 25: Web∩アプリ

Androidのアレって どうつくるんだろう?

25

Page 26: Web∩アプリ

Foxroid

• http://tasdg.co.jp/news/

26

Page 27: Web∩アプリ

Foxroid Tips

• http://tasdg.co.jp/fxos/tips/

27

Page 28: Web∩アプリ

パフォーマンスチューニング

28

Page 29: Web∩アプリ

開発ツール付属のプロファイラ

29

Page 30: Web∩アプリ

メモリ使用量、FPS、ロード、リフロー

30

Page 31: Web∩アプリ

Firefox Powertool

• https://github.com/JonHylands/fxos-powertool

31

Page 32: Web∩アプリ

まとめ

32

Page 33: Web∩アプリ

33

Page 34: Web∩アプリ

34

Page 35: Web∩アプリ

35

https://developer.mozilla.org/MDN