+ All Categories
Home > Technology > Backbone.js, Socket.io und Node.js im Einsatz

Backbone.js, Socket.io und Node.js im Einsatz

Date post: 27-May-2015
Category:
Upload: sebastian-springer
View: 2,320 times
Download: 1 times
Share this document with a friend
Description:
Talk auf der webtechcon 2012 in Mainz
52
BACKBONE, SOCKET.IO UND NODE.JS IM EINSATZ Monday, October 15, 12
Transcript
Page 1: Backbone.js, Socket.io und Node.js im Einsatz

BACKBONE, SOCKET.IO UND NODE.JS IM EINSATZ

Monday, October 15, 12

Page 2: Backbone.js, Socket.io und Node.js im Einsatz

Monday, October 15, 12

Page 3: Backbone.js, Socket.io und Node.js im Einsatz

WER BIN ICH?

• Sebastian Springer

• 29

•Dipl. Inf. (FH)

• Teamleiter @ Mayflower

Monday, October 15, 12

Page 4: Backbone.js, Socket.io und Node.js im Einsatz

WER SEID IHR?

Monday, October 15, 12

Page 5: Backbone.js, Socket.io und Node.js im Einsatz

JAVASCRIPT?

Monday, October 15, 12

Page 6: Backbone.js, Socket.io und Node.js im Einsatz

BACKBONE?

Monday, October 15, 12

Page 7: Backbone.js, Socket.io und Node.js im Einsatz

NODE.JS?

Monday, October 15, 12

Page 8: Backbone.js, Socket.io und Node.js im Einsatz

WAS ERWARTET EUCH

• Vorstellung verschiedener Frameworks

• Zusammenspiel der Frameworks

• ...sehr wenig HTML5

Monday, October 15, 12

Page 9: Backbone.js, Socket.io und Node.js im Einsatz

DER ERSTE VERSUCHBackbone.sync überschreiben

Monday, October 15, 12

Page 10: Backbone.js, Socket.io und Node.js im Einsatz

DEMO

Monday, October 15, 12

Page 11: Backbone.js, Socket.io und Node.js im Einsatz

Webserver Node.js

Client

HTML,

CSS, JS W

ebsockets

Monday, October 15, 12

Page 12: Backbone.js, Socket.io und Node.js im Einsatz

DIE KOMPONENTEN

• Client

• require.js

• Backbone.js

• jQuery

• Underscore.js

• Socket.IO

• Server

•Node.js

• Socket.IO

•Nginx

Monday, October 15, 12

Page 13: Backbone.js, Socket.io und Node.js im Einsatz

DIE CLIENT SEITE

Monday, October 15, 12

Page 14: Backbone.js, Socket.io und Node.js im Einsatz

REQUIRE.JS

•Module Loader (CommonJS)

• Lädt Dateien

• Löst Abhängigkeiten auf

• (Fast) keine <script>-Tags mehr

Monday, October 15, 12

Page 15: Backbone.js, Socket.io und Node.js im Einsatz

INDEX.HTML

Monday, October 15, 12

Page 16: Backbone.js, Socket.io und Node.js im Einsatz

JS/MAIN.JS

Monday, October 15, 12

Page 17: Backbone.js, Socket.io und Node.js im Einsatz

JQUERY

•Wird von Backbone.js benötigt

•DOM-Operationen

• Ajax-Funktionalität

• Alternative: Zepto

Monday, October 15, 12

Page 18: Backbone.js, Socket.io und Node.js im Einsatz

UNDERSCORE

•Wird von Backbone.js benötigt

• Utility-Funktionen (z.B. für Collections)

Monday, October 15, 12

Page 19: Backbone.js, Socket.io und Node.js im Einsatz

BACKBONE.JS

•MVC Framework

• Struktur für Javascript

• REST Infrastruktur

• Abhängigkeiten: jQuery und underscore.js

Monday, October 15, 12

Page 20: Backbone.js, Socket.io und Node.js im Einsatz

BACKBONE.JS

Router

Model

View

Collection

ModelModel

Server

REST

URL

HTML

User

Monday, October 15, 12

Page 21: Backbone.js, Socket.io und Node.js im Einsatz

BACKBONE - ROUTER

• “”: “myFunc”

• “hello”: “world”

• “search/:query”: “search” // #search/backbone

• “search/:query/p:page”: “search” // #search/backbone/p2

Monday, October 15, 12

Page 22: Backbone.js, Socket.io und Node.js im Einsatz

BACKBONE - ROUTER

Monday, October 15, 12

Page 23: Backbone.js, Socket.io und Node.js im Einsatz

BACKBONE - CONTROLLER

• Entlastet den Router

• Instantiiert Model und View

• Schafft die Verbindung zwischen Model und View

Monday, October 15, 12

Page 24: Backbone.js, Socket.io und Node.js im Einsatz

BACKBONE - CONTROLLER

Monday, October 15, 12

Page 25: Backbone.js, Socket.io und Node.js im Einsatz

BACKBONE - MODEL

• REST-API (GET, POST, PUT, DELETE)

• get/set für Property Access (via attributes)

• id-Property

• url als REST location

Monday, October 15, 12

Page 26: Backbone.js, Socket.io und Node.js im Einsatz

BACKBONE - MODEL

Monday, October 15, 12

Page 27: Backbone.js, Socket.io und Node.js im Einsatz

BACKBONE - VIEW

• 2 Komponenten

• js-File mit View-Logik

• Template mit HTML

• Reagiert auf Änderungen des Models

Monday, October 15, 12

Page 28: Backbone.js, Socket.io und Node.js im Einsatz

BACKBONE - VIEW

Monday, October 15, 12

Page 29: Backbone.js, Socket.io und Node.js im Einsatz

BACKBONE - TEMPLATE

Monday, October 15, 12

Page 30: Backbone.js, Socket.io und Node.js im Einsatz

BACKBONE - COLLECTION

• Sammlung von Models

• Utility Funktionen wie each, map, reduce, find, filter

•Models erstellen (add/create)

•Models entfernen (remove)

Monday, October 15, 12

Page 31: Backbone.js, Socket.io und Node.js im Einsatz

SOCKET.IO

• Library zur Bidirektionalen Client-Server-Kommunikation

• Fallbackstrategie: Websockets, Flashsockets, XHR Longpolling

Monday, October 15, 12

Page 32: Backbone.js, Socket.io und Node.js im Einsatz

BACKBONE.SYNC

• Übernimmt die REST Kommunikation

• Änderungen:

• URL + Payload

• Callbacks registrieren

• Umgang mit den Replies

Monday, October 15, 12

Page 33: Backbone.js, Socket.io und Node.js im Einsatz

BACKBONE.SYNC

Monday, October 15, 12

Page 34: Backbone.js, Socket.io und Node.js im Einsatz

DIE SERVER SEITE

Monday, October 15, 12

Page 35: Backbone.js, Socket.io und Node.js im Einsatz

NGINX

Monday, October 15, 12

Page 36: Backbone.js, Socket.io und Node.js im Einsatz

NODE.JS

• serverseitiges Javascript

• V8 Engine

• Eventloop

• Asynchrones I/O

Monday, October 15, 12

Page 37: Backbone.js, Socket.io und Node.js im Einsatz

NODE.JS - NPM

•Node Package Manager

• Repository: npmjs.org

• npm install socket.io

• npm install mysql

Monday, October 15, 12

Page 38: Backbone.js, Socket.io und Node.js im Einsatz

NODE.JS

Monday, October 15, 12

Page 39: Backbone.js, Socket.io und Node.js im Einsatz

DIE NACHTEILE

• Backbone.sync muss überschrieben werden

• REST Schnittstelle kann nicht genutzt werden

Monday, October 15, 12

Page 40: Backbone.js, Socket.io und Node.js im Einsatz

DER ZWEITE VERSUCHREST und Websockets in Coexistenz

Monday, October 15, 12

Page 41: Backbone.js, Socket.io und Node.js im Einsatz

DEMO

Monday, October 15, 12

Page 42: Backbone.js, Socket.io und Node.js im Einsatz

Webserver Node.js

Client

HTML,

CSS, JS W

ebsockets

REST

Monday, October 15, 12

Page 43: Backbone.js, Socket.io und Node.js im Einsatz

DIE CLIENT SEITE

Monday, October 15, 12

Page 44: Backbone.js, Socket.io und Node.js im Einsatz

BACKBONE.JS

• Keine Anpassungen notwendig

Monday, October 15, 12

Page 45: Backbone.js, Socket.io und Node.js im Einsatz

SOCKET.IO

router.js

controller.js

Monday, October 15, 12

Page 46: Backbone.js, Socket.io und Node.js im Einsatz

DIE SERVER SEITE

Monday, October 15, 12

Page 47: Backbone.js, Socket.io und Node.js im Einsatz

NGINX

Monday, October 15, 12

Page 48: Backbone.js, Socket.io und Node.js im Einsatz

NODE.JS

Monday, October 15, 12

Page 49: Backbone.js, Socket.io und Node.js im Einsatz

NODE.JS

Monday, October 15, 12

Page 50: Backbone.js, Socket.io und Node.js im Einsatz

FRAGEN?

Monday, October 15, 12

Page 51: Backbone.js, Socket.io und Node.js im Einsatz

http://joind.in/talk/view/7301

Monday, October 15, 12

Page 52: Backbone.js, Socket.io und Node.js im Einsatz

KONTAKT

Sebastian [email protected]

Mayflower GmbHMannhardtstr. 680538 MünchenDeutschland

@basti_springer

https://github.com/sspringer82

Monday, October 15, 12


Recommended