RT-MVC Real Time Model/View/Controller Applications Daniel Erickson - - PowerPoint PPT Presentation

rt mvc
SMART_READER_LITE
LIVE PREVIEW

RT-MVC Real Time Model/View/Controller Applications Daniel Erickson - - PowerPoint PPT Presentation

11/7/12 Real Time and MVC with GeddyJS RT-MVC Real Time Model/View/Controller Applications Daniel Erickson qConSF / file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?printpdf#/1 1/30 11/7/12 Real Time and MVC


slide-1
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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

  • pen bugs on github

send us pull requests http://geddyjs.org

slide-29
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
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