Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Building Real-Time Applications in Ember.js
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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
26
React_Performance__2022.pdf
stevekinney
0
31
React Performance v2
stevekinney
0
47
Introduction to Testing
stevekinney
0
170
Web Security, Frontend Masters
stevekinney
0
3.9k
Making Music with the Web Audio API, JSConf Colombia 2023
stevekinney
0
120
React and TypeScript, Turing School
stevekinney
0
380
Redux Workshop, 2021-05-05
stevekinney
2
2.2k
TypeScript and React Utility Types
stevekinney
1
220
Other Decks in Technology
See All in Technology
新しいVibe Codingと”自走”について
watany
6
320
2026 TECHFRESH 畢業分享會 - 開發日常大解密!從領域驅動到企業級上線
line_developers_tw
PRO
0
1k
アンオフィシャルな、オフィシャルからのお願い
wyamazak_devrel
0
110
Disciplined Vibes: Scaling AI-Assisted Engineering
sheharyar
0
140
AIソロプレナー時代に2ヶ月で20人増員した事業創造会社の開発組織の話
miyatakoji
0
660
【Snowflake Summit 2026 Recap!!】Snowflake Summit Deep Dive: Security & Governance
civitaspo
1
170
人材育成分科会.pdf
_awache
4
250
2026TECHFRESH畢業分享會 - Lightning Talk - 資料也要 CI/CD? 用 Airbyte 自動化資料同步
line_developers_tw
PRO
0
1k
失敗を資産に変えるClaude Code
shinyasaita
0
650
On-behalf-of Token exchange with AgentCore Identity
hironobuiga
2
200
エラーバジェットのアラートのタイミングを考える.pdf
kairim0
0
150
就職⽀援サービスにおけるキャリアアドバイザーのシフトスケジューリング
recruitengineers
PRO
1
140
Featured
See All Featured
The Illustrated Children's Guide to Kubernetes
chrisshort
51
52k
Reality Check: Gamification 10 Years Later
codingconduct
0
2.2k
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
370
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.2k
A Modern Web Designer's Workflow
chriscoyier
698
190k
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
160
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
160
It's Worth the Effort
3n
188
29k
Producing Creativity
orderedlist
PRO
348
40k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.8k
Exploring anti-patterns in Rails
aemeredith
3
410
Speed Design
sergeychernyshev
33
1.8k
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/