1 of 43

Meteor

A platform to develop modern applications faster than you ever thought

José Cabo Carsí josecabocarsi@gmail.com @JoseCaboCarsi /in/josecabo

2 of 43

We are going to cover about...

  1. What is Meteor
  2. Database. Everywhere.
  3. Blaze & templating
  4. Securing our application
  5. Latency Compensation
  6. Publish and subscribe
  7. Let’s embrace the platform

3 of 43

But we will not cover...

4 of 43

Typical application workflow

MVC in server - Symfony2

Routing

Controller

Templating

Browser

Html

+ javascript

Ajax!

Model

Server basic MVC - REST

Ajax!

Routing

Controller

Templating

Model

5 of 43

Imperative/conventional style Coding

  • Code how to get your data
  • Code from where to get it
  • CRUD the interface with your data

6 of 43

7 of 43

8 of 43

What is Meteor?

The 10th of the most starred github project at date

The 6th of javascript projects

9 of 43

What is Meteor?

  • Javascript everywhere
  • One code to rule them all (uses node.js as its own framework)
  • Web applications and web apps

10 of 43

What is Meteor?

  • Client-server integration
  • No callback-hell
  • Automatisms (F5, minification, etc)
  • Several subprojects
  • MongoDB
  • Hot-updates

11 of 43

Installing meteor

$ curl https://install.meteor.com/ | sh

$ meteor create <application-name>�$ cd <application-name>

$ MONGO_URL=mongodb://localhost:27017/your_db meteor

12 of 43

Reactivity? Uh?

  • Vars: a := 3, b := 2
  • c := a + b
  • Result: c := 5

If after: b := 3

  • Result: c := 5

(Unless explicit reexecution)

With Reactivity:

If after: b := 3

  • Result: c := 6

13 of 43

More

14 of 43

Meteor’s Full-Stack Reactivity

(client)�Minimongo

Server

(client)Minimongo

Meteor data platform

15 of 43

MongoDB and minimongo

  • Database everywhere

Real-time and multi-client data, by default

//Client

//Other client

16 of 43

MongoDB and minimongo

17 of 43

More about mongoDB

18 of 43

Blaze & templating

  • Spacebars, Meteor's dialect of Handlebars
  • Logic-less template engine
  • Super Ultra reactive

19 of 43

Blaze & templating

  • Blaze reactivity works thanks to template’s helpers
  • Reactively, they keep the interface updated

20 of 43

Events and meteor sessions

21 of 43

Tips

  • When coding the layout try to represent a data state
  • Never store the current interface state in DB

22 of 43

More

23 of 43

Securing our application

Reasons:

  • Never trust the client
  • Data verification
  • Secret server code
  • ...

Revokes all client’s database writes

24 of 43

Securing our application

Special directories:

  • client/
  • server/

  • */client/
  • */server/

25 of 43

Securing our application

26 of 43

Securing our application

27 of 43

Securing our application

Problems:

  • Network latency
  • User Interface is not updated instantly
  • Bad feedback to user
  • Against everything we have already seen

28 of 43

Latency Compensation

It is possible to avoid network latency

  • It simulates an execution in the client to predict server’s answer
  • The UI updates instantly (delay = 0)
  • After, if the simulation is correct, the UI remains the same

29 of 43

Latency Compensation

Two different codes:

  • Real in /server
  • Simulation in /client

Same code in both sides.

30 of 43

More

31 of 43

Publish and Subscribe

So… the entire database is present in the client?

Where is all my data?!

32 of 43

Publish and Subscribe

To execute only in server

To execute only in client

  • Accepts parameters

  • Used to know when data is available in client

33 of 43

More

34 of 43

Embrace the platform

$ meteor add repo:name

35 of 43

Embrace the platform

  • accounts-ui
  • accounts-password
  • iron:router
  • aldeed:collection2
  • msavin:mongol

Warning!:

  • insecure
  • autopublish

36 of 43

More

37 of 43

Embrace the platform

DDP client

DDP Server

DDP client

Meteor platform

(over websocket)

DDP

(over websocket)

DDP

Livequery

38 of 43

More

39 of 43

Easy deploying

$ meteor deploy <destination>

http://<destination>.meteor.com

Free and automatic meteor host

40 of 43

More

41 of 43

Thanks!

42 of 43

By Francisco López

43 of 43