11/7/12 real time and mvc with geddyjs rt-mvc · 11/7/12 real time and mvc with geddyjs...

30
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

Upload: others

Post on 22-Jul-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 11/7/12 Real Time and MVC with GeddyJS RT-MVC · 11/7/12 Real Time and MVC with GeddyJS file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1 13/30

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

Page 2: 11/7/12 Real Time and MVC with GeddyJS RT-MVC · 11/7/12 Real Time and MVC with GeddyJS file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1 13/30

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?

Page 3: 11/7/12 Real Time and MVC with GeddyJS RT-MVC · 11/7/12 Real Time and MVC with GeddyJS file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1 13/30

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?

Page 4: 11/7/12 Real Time and MVC with GeddyJS RT-MVC · 11/7/12 Real Time and MVC with GeddyJS file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1 13/30

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

Page 5: 11/7/12 Real Time and MVC with GeddyJS RT-MVC · 11/7/12 Real Time and MVC with GeddyJS file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1 13/30

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

Page 6: 11/7/12 Real Time and MVC with GeddyJS RT-MVC · 11/7/12 Real Time and MVC with GeddyJS file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1 13/30

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?

Page 7: 11/7/12 Real Time and MVC with GeddyJS RT-MVC · 11/7/12 Real Time and MVC with GeddyJS file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1 13/30

11/7/12 Real Time and MVC with GeddyJS

7/30file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1

MVC?

Page 8: 11/7/12 Real Time and MVC with GeddyJS RT-MVC · 11/7/12 Real Time and MVC with GeddyJS file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1 13/30

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

Page 9: 11/7/12 Real Time and MVC with GeddyJS RT-MVC · 11/7/12 Real Time and MVC with GeddyJS file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1 13/30

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

Page 10: 11/7/12 Real Time and MVC with GeddyJS RT-MVC · 11/7/12 Real Time and MVC with GeddyJS file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1 13/30

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?

Page 11: 11/7/12 Real Time and MVC with GeddyJS RT-MVC · 11/7/12 Real Time and MVC with GeddyJS file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1 13/30

11/7/12 Real Time and MVC with GeddyJS

11/30file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1

BOTH!

Page 12: 11/7/12 Real Time and MVC with GeddyJS RT-MVC · 11/7/12 Real Time and MVC with GeddyJS file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1 13/30

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

Page 13: 11/7/12 Real Time and MVC with GeddyJS RT-MVC · 11/7/12 Real Time and MVC with GeddyJS file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1 13/30

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

Page 14: 11/7/12 Real Time and MVC with GeddyJS RT-MVC · 11/7/12 Real Time and MVC with GeddyJS file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1 13/30

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

Page 15: 11/7/12 Real Time and MVC with GeddyJS RT-MVC · 11/7/12 Real Time and MVC with GeddyJS file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1 13/30

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?

Page 16: 11/7/12 Real Time and MVC with GeddyJS RT-MVC · 11/7/12 Real Time and MVC with GeddyJS file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1 13/30

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

Page 17: 11/7/12 Real Time and MVC with GeddyJS RT-MVC · 11/7/12 Real Time and MVC with GeddyJS file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1 13/30

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

Page 18: 11/7/12 Real Time and MVC with GeddyJS RT-MVC · 11/7/12 Real Time and MVC with GeddyJS file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1 13/30

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

Page 19: 11/7/12 Real Time and MVC with GeddyJS RT-MVC · 11/7/12 Real Time and MVC with GeddyJS file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1 13/30

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

Page 20: 11/7/12 Real Time and MVC with GeddyJS RT-MVC · 11/7/12 Real Time and MVC with GeddyJS file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1 13/30

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

Page 21: 11/7/12 Real Time and MVC with GeddyJS RT-MVC · 11/7/12 Real Time and MVC with GeddyJS file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1 13/30

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.

Page 22: 11/7/12 Real Time and MVC with GeddyJS RT-MVC · 11/7/12 Real Time and MVC with GeddyJS file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1 13/30

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

Page 23: 11/7/12 Real Time and MVC with GeddyJS RT-MVC · 11/7/12 Real Time and MVC with GeddyJS file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1 13/30

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

Page 24: 11/7/12 Real Time and MVC with GeddyJS RT-MVC · 11/7/12 Real Time and MVC with GeddyJS file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1 13/30

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

Page 25: 11/7/12 Real Time and MVC with GeddyJS RT-MVC · 11/7/12 Real Time and MVC with GeddyJS file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1 13/30

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

Page 26: 11/7/12 Real Time and MVC with GeddyJS RT-MVC · 11/7/12 Real Time and MVC with GeddyJS file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1 13/30

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

Page 27: 11/7/12 Real Time and MVC with GeddyJS RT-MVC · 11/7/12 Real Time and MVC with GeddyJS file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1 13/30

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

Page 28: 11/7/12 Real Time and MVC with GeddyJS RT-MVC · 11/7/12 Real Time and MVC with GeddyJS file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1 13/30

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

Page 29: 11/7/12 Real Time and MVC with GeddyJS RT-MVC · 11/7/12 Real Time and MVC with GeddyJS file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1 13/30

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?

Page 30: 11/7/12 Real Time and MVC with GeddyJS RT-MVC · 11/7/12 Real Time and MVC with GeddyJS file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1 13/30

11/7/12 Real Time and MVC with GeddyJS

30/30file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1