11/7/12 real time and mvc with geddyjs rt-mvc · 11/7/12 real time and mvc with geddyjs...
TRANSCRIPT
11/7/12 Real Time and MVC with GeddyJS
1/30file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
RT-MVCReal Time Model/View/Controller Applications
/ Daniel Erickson qConSF
11/7/12 Real Time and MVC with GeddyJS
2/30file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
WHAT'S GOING TOWIN
REAL TIME OR MVC?
11/7/12 Real Time and MVC with GeddyJS
3/30file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
REAL TIME?
11/7/12 Real Time and MVC with GeddyJS
4/30file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
YEAH!'CUZ SOME PEOPLE SAY:
MVC doesn't scale wellMVC is dead
11/7/12 Real Time and MVC with GeddyJS
5/30file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
BUT MVC IS HERE TO STAYGives teams structure to get things doneAllows new people to jump into your projectEasy to get started with
11/7/12 Real Time and MVC with GeddyJS
6/30file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
WHAT'S GOING TOWIN
REAL TIME OR MVC?
11/7/12 Real Time and MVC with GeddyJS
7/30file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
MVC?
11/7/12 Real Time and MVC with GeddyJS
8/30file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
TOTALLY!'CUZ PEOPLE THINK:
Real Time is hardMaintain a new stackEvent Machine and Tornado suckFront end code is messy
11/7/12 Real Time and MVC with GeddyJS
9/30file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
BUT REAL TIME IS ALSO HERE TO STAYUse WebSockets to get updates on the front endInstant feedback for your usersWorks really well on mobile
11/7/12 Real Time and MVC with GeddyJS
10/30file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
WHAT'S GOING TOWIN
REAL TIME OR MVC?
11/7/12 Real Time and MVC with GeddyJS
11/30file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
BOTH!
11/7/12 Real Time and MVC with GeddyJS
12/30file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
REAL TIME AND MVCACTUALLY MIX PRETTY WELL
11/7/12 Real Time and MVC with GeddyJS
13/30file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
YOU CAN:Define your model once and use it all over the placeuse your templates on both sides of HTTPMirror events from the backend to the frontend
instance createdinstace updatedinstance removed
11/7/12 Real Time and MVC with GeddyJS
14/30file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
HOW WE SOLVED THEREAL TIME PROBLEM
WITH GEDDY
11/7/12 Real Time and MVC with GeddyJS
15/30file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
WAIT,WHAT'S GEDDY?
11/7/12 Real Time and MVC with GeddyJS
16/30file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
THE ORIGINAL MVCFRAMEWORK FOR NODE.JS
Very familiar if you know RailsAwesome noSQL and SQL ORMMany different templating languages
11/7/12 Real Time and MVC with GeddyJS
17/30file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
AND NOW ITSUPPORTS REAL TIME
RIGHT OUT OF THE BOX
11/7/12 Real Time and MVC with GeddyJS
18/30file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
SO LETS MAKE AN MVC APPTHAT SUPPORTS REAL TIME
11/7/12 Real Time and MVC with GeddyJS
19/30file://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
11/7/12 Real Time and MVC with GeddyJS
20/30file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
TEST IT OUTOpen up and
http://localhost:4000/thingshttp://localhost:4000/things/add
11/7/12 Real Time and MVC with GeddyJS
21/30file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
FOR THOSE OF YOU FOLLOWINGALONG AT HOME
1. add a thing2. watch it show up in the other window3. update the thing4. watch it change in the other window5. remove the item6. watch it get removed from the other window.
11/7/12 Real Time and MVC with GeddyJS
22/30file://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
11/7/12 Real Time and MVC with GeddyJS
23/30file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
WHAT JUST HAPPENED?geddy scaffold -rt thing ...
Generated a thing resource
thing modelmade that model available on the front endthings controllerroutesviews that subscribe to the realtime events
11/7/12 Real Time and MVC with GeddyJS
24/30file://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 filecopies your models over to a public js filesets up listeners for each model's lifecycle eventsproxies those lifecycle events to socket.io
11/7/12 Real Time and MVC with GeddyJS
25/30file://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 eventsproxies them to the appropriate modelsscaffolds some code that hooks into real time events
11/7/12 Real Time and MVC with GeddyJS
26/30file://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 everywhereemit custom events on your modelsall generated code can be modified
11/7/12 Real Time and MVC with GeddyJS
27/30file://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 ORMReal time queriesPer instance real time eventsA better way to share templates
11/7/12 Real Time and MVC with GeddyJS
28/30file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
WANT TO HELP OUT?CHECK OUT GEDDY AT
Join the mailinglistopen bugs on githubsend us pull requests
http://geddyjs.org
11/7/12 Real Time and MVC with GeddyJS
29/30file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
ANY QUESTIONS?
11/7/12 Real Time and MVC with GeddyJS
30/30file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1