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
What Do You Know: StateCharts
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
geoffreyd
February 28, 2012
Programming
170
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
What Do You Know: StateCharts
Presentation for the WebDirections What Do You Know night.
geoffreyd
February 28, 2012
Other Decks in Programming
See All in Programming
LLM本来の能力を解き放つサンドボックス技術とAI民主化への適用
yukukotani
3
4.6k
フロントエンドとバックエンドで「1文字」を揃えよう
youkidearitai
PRO
0
750
セキュリティの専門家じゃなくてもできる。「セキュリティ意識」をアップデートして サプライチェーン攻撃への耐性を高めよう。
tk3fftk
5
970
脅威をエンジニアリングの糧にして――現場編 / Turning Threats into Engineering Fuel — Field Edition
nrslib
0
300
任せる範囲はこう広がった / How the Scope of AI Delegation Has Expanded
nrslib
0
160
Creating Composable Callables in Contemporary C++
rollbear
0
170
どこまでゆるくて許されるのか
tk3fftk
0
260
そのテスト、説明できますか?~LWテスト戦略FW~のご紹介
nakahara
0
170
Hunting Vulnerabilities in Symfony with LLMs
vinceamstoutz
0
560
TypeScript+Orvalで実現する型安全かつ堅牢でスケーラブルなマルチチャネル通知基盤 / TSKaigi Night talks ~after conference~
d0riven
0
360
はてなアカウント基盤 State of the Union
cockscomb
1
910
LLMによるContent Moderationの本番運用の裏側と品質担保への挑戦
suikabar
3
790
Featured
See All Featured
Leo the Paperboy
mayatellez
7
1.9k
Fireside Chat
paigeccino
42
4k
How STYLIGHT went responsive
nonsquared
100
6.2k
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6k
Navigating Weather and Climate Data
rabernat
0
250
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
2
250
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
330
Design in an AI World
tapps
1
250
A designer walks into a library…
pauljervisheath
211
24k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
340
Transcript
Simplify your Events Geoffrey Donaldson @geoffreyd
So you’re building an App?
The Cool Cats Say • Design: MVC, MVVM, MVP •
Framework: Backbone, Batman, Sammy, SproutCore, JavascriptMVC ... • Templates: Handlebars, Moustache, Jade, Plain old HTML ...
View View Controller Model
View View Controller Model
View View Controller Model
Data View Controller Model
Data View Controller Model
Events ? View Controller Model
Events ? View Controller Model
Events ? View Controller Model
Errrr
Events ? View Controller Model
Events ? View Controller Model
Which One? Views User Controller Models Contact Controller Client Controller
Booking Controller Login Controller
StateCharts Logic Controllers for your App Login (Is NOT logged
in) CHECK AUTHORIZATION endLogin Show Login Running (Is Logged in) beginLogin
Which One? Views Models User Controller Contact Controller Client Controller
Booking Controller Login Controller
StateCharts - Logic Controllers Views User Controller Models Contact Controller
Client Controller Booking Controller Login Controller StateChart
Data Goes to Views Views User Controller Models Contact Controller
Client Controller Booking Controller Login Controller StateChart
Events Goes to StateChart Views User Controller Models Contact Controller
Client Controller Booking Controller Login Controller StateChart
StateChart Respond to Events Views User Controller Models Contact Controller
Client Controller Booking Controller Login Controller StateChart
Responsible for View Setup Views User Controller Models Contact Controller
Client Controller Booking Controller Login Controller StateChart
So How does it work? Show me already!!
Login (Is NOT logged in) CHECK AUTHORIZATION endLogin Show Login
Running (Is Logged in) beginLogin
Login (Is NOT logged in) CHECK AUTHORIZATION endLogin Show Login
Running (Is Logged in) beginLogin statechart.addState({ parentState: “App”, name: “login”, initialSubState: “checkAuthorization” })
statechart.addState({ name: “checkAuthorization”, parentState: “login”, enterState: function() { if (userLoggedIn())
{ this.goToState(“Running”) } else { this.goToState(“ShowLogin”) } } }) Login (Is NOT logged in) CHECK AUTHORIZATION endLogin Show Login Running (Is Logged in) beginLogin
statechart.addState({ name: “showLogin”, parentState: “login”, enterState: function() { // Show
Login View }, exitState: function() { // Hide Login View }, beginLogin: function() { // Send data to server }, endLogin: function() { // Receive response, Then go to Running State } }) Login (Is NOT logged in) CHECK AUTHORIZATION endLogin Show Login Running (Is Logged in) beginLogin
statechart.addState({ name: “Running”, parentState: “App”, enterState: function() { // Show
App Views }, exitState: function() { // Hide App Views } }) Login (Is NOT logged in) CHECK AUTHORIZATION endLogin Show Login Running (Is Logged in) beginLogin
Login (Is NOT logged in) CHECK AUTHORIZATION endLogin Show Login
Running (Is Logged in) beginLogin Testing
Login (Is NOT logged in) CHECK AUTHORIZATION endLogin Show Login
Running (Is Logged in) beginLogin Testing Pass 1 Logged Out, Successful response
Login (Is NOT logged in) CHECK AUTHORIZATION endLogin Show Login
Running (Is Logged in) beginLogin Pass 1 Logged Out, Successful response Pass 2 Logged Out, Failed response Testing
Login (Is NOT logged in) CHECK AUTHORIZATION endLogin Show Login
Running (Is Logged in) beginLogin Pass 1 Logged Out, Successful response Pass 2 Logged Out, Failed response Pass 3 Already Logged In Testing
Login (Is NOT logged in) CHECK AUTHORIZATION endLogin Show Login
Running (Is Logged in) beginLogin Pass 1 Logged Out, Successful response Pass 2 Logged Out, Failed response Pass 3 Already Logged In Testing DONE!
StateCharts • Put your App logic in the right place
• Each State is responsible for it’s visual state • Separate concerns • Easy to Test
StateCharts You to can use them github.com/etgryphon/stativus