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
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
柔軟なPDFレイアウトエディタを支える型システム設計 — Discriminated UnionとConditional Typeの実践
minako__ph
4
1.4k
RTSPクライアントを自作してみた話
simotin13
0
460
「AIで開発し、AIを届ける」をEvalでつなぐ 〜AIネイティブに始めるプロダクト開発の実践〜 / Connecting "Develop with AI, deliver AI" with Eval
rkaga
4
2.2k
キャリア迷子上等 ─ "ない道"は自分で作ればいい
16bitidol
2
330
AIエージェントと協働するCLI開発 — BunとOpenClawで学んだこと
yoshikouki
1
230
TSKaigi Night Talks 2026_TypeScriptでサプライチェーンの整合性を型に閉じ込める
geekplus_tech
0
280
密結合なバックエンドから TypeScript のコードを生成する
kemuridama
1
720
jQueryをバージョンアップする前に使いたいjQuery Migrate
matsuo_atsushi
0
180
OSもどきOS
arkw
0
410
TAKTでAI駆動開発の品質を設計する
j5ik2o
6
870
PHPで使える日時の表現と、その知り方 #frontend_phpcon_do
o0h
PRO
0
190
AIとASP.NET Coreで雑Webアプリを作った話
mayuki
0
300
Featured
See All Featured
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
130
Prompt Engineering for Job Search
mfonobong
0
330
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
1
2.7k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
230
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
4k
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
280
Fashionably flexible responsive web design (full day workshop)
malarkey
408
66k
HDC tutorial
michielstock
2
690
What does AI have to do with Human Rights?
axbom
PRO
1
2.2k
Side Projects
sachag
455
43k
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
320
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
140
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