Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Building Real-Time Applications in Ember.js
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Steve Kinney
March 04, 2015
Technology
130
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Building Real-Time Applications in Ember.js
Steve Kinney
March 04, 2015
More Decks by Steve Kinney
See All by Steve Kinney
Enterprise UI, v2
stevekinney
0
270
React_Performance__2022.pdf
stevekinney
0
46
React Performance v2
stevekinney
0
76
Introduction to Testing
stevekinney
0
190
Web Security, Frontend Masters
stevekinney
0
4.4k
Making Music with the Web Audio API, JSConf Colombia 2023
stevekinney
0
140
React and TypeScript, Turing School
stevekinney
0
390
Redux Workshop, 2021-05-05
stevekinney
2
2.2k
TypeScript and React Utility Types
stevekinney
1
230
Other Decks in Technology
See All in Technology
AI臭い文章とは何なのか
nasuvitz
36
76k
個別開発で終わらせない。 現場の課題をプロダクトの強さに変える StockmarkのFDE
ktkrhr
0
490
GitHub Agentic Workflows を触ってみる
htkym
2
900
Lambda MicroVMsが分からなすぎたので使い所を1から考えてみた
tsukuboshi
1
270
Codex概要
ymiya55
0
140
KanaAI
shreyas1009
0
140
企業の現実世界をグラフで写し取る
sansantech
PRO
0
230
React Nativeでの OTA Updateって、 どう説明する?
ichiki1023
0
130
AgentCoreで実践するハーネスエンジニアリング
yakumo
0
100
BedrockとLambdaで作る リアルタイム進行型推理ゲーム
kawametho
0
140
AIに書かせて、プラットフォームで縛る ― EKSプラットフォームで実践した責任境界と権限設計
elmodev09
1
1.1k
DORA_Metrics.pdf
wagnerfusca
1
140
Featured
See All Featured
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
720
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
340
A Soul's Torment
seathinner
8
3.7k
How Software Deployment tools have changed in the past 20 years
geshan
2
34k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
1.3k
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
1
3.2k
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
780
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
12k
Navigating Weather and Climate Data
rabernat
0
540
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6.1k
Producing Creativity
orderedlist
PRO
348
41k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.5k
Transcript
Building Real-Time Applications in Ember EmberConf 2015
Hi. I'm Steve. @stevekinney |
[email protected]
None
None
Let's talk about building real-time applications with Ember.
This is a story about WebSockets…
It's also a story about integrating all sorts of browser
functionality and third-party code into our applications.
What even is a WebSocket?
WebSockets are an HTTP independent, bi-directional, TCP-based protocol over port
80 standardized in 2011 by the IETF as RFC 6455.
Duh.
None
What are WebSockets used for?
Quick Demo
Can I actually use WebSockets?
None
None
Now, that we know everything there is to know about
WebSockets, let’s get to implementing them.
None
None
Step Zero: We need a WebSocket server, right?
A WebSocket server in fourteen lines.
var WebSocketServer = require('ws').Server; var socket = new WebSocketServer({ port:
8080 }); socket.on('connection', function(connection) { connection.on('message', function(message) { socket.broadcast(message); }); }); socket.broadcast = function(data) { this.clients.forEach(function (client) { client.send(data); }); };
What does this look like on the client?
A Traditional Example var socket = io(); $('form').submit(function(){ socket.emit('chat message',
$('#m').val()); $('#m').val(''); return false; }); socket.on('chat message', function(msg){ $('#messages').append($('<li>').text(msg)); });
Ugh. DOM/selector- based development. #fail
—Erik Bryn “Selector-based programming”
We can do better.
Let's try two or three different approaches.
Approach #1: A standalone controller
ember generate controller websocket
app/controllers/ websocket.js
None
None
None
None
None
None
None
None
None
None
app/controllers/ chatroom.js
None
None
None
None
None
None
None
app/routes/ chatroom.js
None
None
Quick Demo
This approach works great, but it's somewhat limited.
None
Approach #2: Dependency Injection with Services
ember generate service websocket
installing create app/services/websocket.js create app/initializers/websocket.js
app/initializers/ websocket.js
None
None
None
None
None
Let's move that code from the controller into our service.
rm -rf app/controllers/websocket.js
app/controllers/ chatroom.js
None
None
That's it.
Approach #3: Using Socket.io
Point of Interest: Socket.io is both a server- and client-
side library.
To each her own.
Let's set up a Socket.io server
None
None
bower install sio-client
None
app/services/ websocket.js
None
app/controllers/ chatroom.js
None
None
Thank you. Code example: stevekinney/emberconf-chat Twitter and Github: @stevekinney Email:
[email protected]
Hire our students: http://people.turing.io/