SLIDE 1 11/7/12 Real Time and MVC with GeddyJS 1/30 file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
RT-MVC
Real Time Model/View/Controller Applications / Daniel Erickson qConSF
SLIDE 2 11/7/12 Real Time and MVC with GeddyJS 2/30 file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
WHAT'S GOING TO WIN REAL TIME OR MVC?
SLIDE 3 11/7/12 Real Time and MVC with GeddyJS 3/30 file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
REAL TIME?
SLIDE 4 11/7/12 Real Time and MVC with GeddyJS 4/30 file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
YEAH!
'CUZ SOME PEOPLE SAY:
MVC doesn't scale well MVC is dead
SLIDE 5 11/7/12 Real Time and MVC with GeddyJS 5/30 file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
BUT MVC IS HERE TO STAY
Gives teams structure to get things done Allows new people to jump into your project Easy to get started with
SLIDE 6 11/7/12 Real Time and MVC with GeddyJS 6/30 file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
WHAT'S GOING TO WIN REAL TIME OR MVC?
SLIDE 7 11/7/12 Real Time and MVC with GeddyJS 7/30 file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
MVC?
SLIDE 8 11/7/12 Real Time and MVC with GeddyJS 8/30 file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
TOTALLY!
'CUZ PEOPLE THINK:
Real Time is hard Maintain a new stack Event Machine and Tornado suck Front end code is messy
SLIDE 9 11/7/12 Real Time and MVC with GeddyJS 9/30 file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
BUT REAL TIME IS ALSO HERE TO STAY
Use WebSockets to get updates on the front end Instant feedback for your users Works really well on mobile
SLIDE 10 11/7/12 Real Time and MVC with GeddyJS 10/30 file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
WHAT'S GOING TO WIN REAL TIME OR MVC?
SLIDE 11 11/7/12 Real Time and MVC with GeddyJS 11/30 file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
BOTH!
SLIDE 12 11/7/12 Real Time and MVC with GeddyJS 12/30 file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
REAL TIME AND MVC
ACTUALLY MIX PRETTY WELL
SLIDE 13 11/7/12 Real Time and MVC with GeddyJS 13/30 file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
YOU CAN:
Define your model once and use it all over the place use your templates on both sides of HTTP Mirror events from the backend to the frontend instance created instace updated instance removed
SLIDE 14 11/7/12 Real Time and MVC with GeddyJS 14/30 file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
HOW WE SOLVED THE REAL TIME PROBLEM WITH GEDDY
SLIDE 15 11/7/12 Real Time and MVC with GeddyJS 15/30 file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
WAIT, WHAT'S GEDDY?
SLIDE 16 11/7/12 Real Time and MVC with GeddyJS 16/30 file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
THE ORIGINAL MVC FRAMEWORK FOR NODE.JS
Very familiar if you know Rails Awesome noSQL and SQL ORM Many different templating languages
SLIDE 17 11/7/12 Real Time and MVC with GeddyJS 17/30 file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
AND NOW IT SUPPORTS REAL TIME
RIGHT OUT OF THE BOX
SLIDE 18 11/7/12 Real Time and MVC with GeddyJS 18/30 file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
SO LETS MAKE AN MVC APP THAT SUPPORTS REAL TIME
SLIDE 19 11/7/12 Real Time and MVC with GeddyJS 19/30 file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
GENERATE AN APP
$ npm install -g geddy $ geddy app -rt demo $ cd demo $ geddy scaffold -rt thing title description $ geddy
SLIDE 20 11/7/12 Real Time and MVC with GeddyJS 20/30 file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
TEST IT OUT
Open up and http://localhost:4000/things http://localhost:4000/things/add
SLIDE 21 11/7/12 Real Time and MVC with GeddyJS 21/30 file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
FOR THOSE OF YOU FOLLOWING ALONG AT HOME
- 1. add a thing
- 2. watch it show up in the other window
- 3. update the thing
- 4. watch it change in the other window
- 5. remove the item
- 6. watch it get removed from the other window.
SLIDE 22 11/7/12 Real Time and MVC with GeddyJS 22/30 file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
WHAT JUST HAPPENED?
geddy app -rt demo Generated a demo app with realtime enabled
SLIDE 23 11/7/12 Real Time and MVC with GeddyJS 23/30 file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
WHAT JUST HAPPENED?
geddy scaffold -rt thing ... Generated a thing resource thing model made that model available on the front end things controller routes views that subscribe to the realtime events
SLIDE 24 11/7/12 Real Time and MVC with GeddyJS 24/30 file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
HOW DOES IT WORK?
ON THE SERVER SIDE:
geddy sees the realtime flag in your config file copies your models over to a public js file sets up listeners for each model's lifecycle events proxies those lifecycle events to socket.io
SLIDE 25 11/7/12 Real Time and MVC with GeddyJS 25/30 file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
HOW DOES IT WORK?
ON THE CLIENT SIDE:
registers listeners for all model related events proxies them to the appropriate models scaffolds some code that hooks into real time events
SLIDE 26 11/7/12 Real Time and MVC with GeddyJS 26/30 file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
THATS PRETTY COOL,
BUT IS IT EASY TO CHANGE?
modify your model once and you get it everywhere emit custom events on your models all generated code can be modified
SLIDE 27 11/7/12 Real Time and MVC with GeddyJS 27/30 file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
WHAT'S NEXT ON THE ROADMAP?
Create an AJAX adapter for the front-end ORM Real time queries Per instance real time events A better way to share templates
SLIDE 28 11/7/12 Real Time and MVC with GeddyJS 28/30 file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
WANT TO HELP OUT?
CHECK OUT GEDDY AT
Join the mailinglist
send us pull requests http://geddyjs.org
SLIDE 29 11/7/12 Real Time and MVC with GeddyJS 29/30 file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
ANY QUESTIONS?
SLIDE 30 11/7/12 Real Time and MVC with GeddyJS 30/30 file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1