5. What is Meteor?
● Meteor is an ultra-simple environment for
building modern web and mobile app using
Javascript.
● Build to the power of next generation app
o Rich user interfaces
o Collaborative multi-user applications
o Cross platform apps
o Fast development
6. 7 Meteor Principles
1. Data on the Wire
2. One Language
3. Database Everywhere
4. Latency Compensation
5. Full Stack Reactivity
6. Embrace the Ecosystem
7. Simplicity = Productivity
7. Why Meteor?
● Applications are real-time by default
● Develop with just one language
● Save a lot of time with smart packages
● Optimized for developer happiness
● Friendly to beginner developers
● Ahead of the tech curve
● Community is extremely supportive
8. Data on the Wire
Meteor doesn't send HTML over the network.
The server sends data and lets the client
render it.
9. Data on the Wire (Continue ...)
Traditional Web Architecture
Client
Server
HTTP
HTML
No Persistent Connection
http://www.prothom-alo.com
<html>
…
news - 1
news - 2
...
<.html>
10. Data on the Wire (Continue ...)
Traditional Web Architecture Modern Web Architecture
Client
Server
Client
Server
HTTPHTML
No Persistent Connection Persistent Connection
DDP
<html>
…
news - 1
news - 2
...
<.html>
http://www.prothom-alo.com http://www.prothom-alo.com
<html>
news - 1
news - 2
<.html>
news - 3
.
.
news - 4
.
.
11. DDP - Distributed Data Protocol
A protocol based on JSON.
Technically, DDP can be implemented on top of any
duplex transport. Meteor’s current implementation is
based on WebSockets and SockJS.
SockJS is a WebSockets emulation transport, which can be used when WebSockets is not available.
12. DDP - Distributed Data Protocol
DDP mainly does two things:
● It handles Remote Procedure Calls (RPC).
● It manages data.
13. DDP - Distributed Data Protocol
DDP mainly does two things:
● It handles Remote Procedure Calls (RPC).
● It manages data.
14. Handling Remote Procedure Calls
1. {"msg":"method",
"method":
"transferMoney",
"params": ["1000USD",
"arunoda", "sacha"],
id": "randomId-1"}
2. {"msg": "result", id":
"randomId-1": "result":
"5000USD"}
3. {"msg": "updated",
"methods": ["randomId-
1"]}
It notifies the caller after all the write operations in the method have been reflected to all the
other connected clients.
15. DDP - Managing Data
The DDP protocol has three types of notification: added, changed and
removed
1. The DDP client (sacha) sends a
subscription request for his account.
2. He will receive a couple of added
notifications with the current
transactions in his account.
3. After all the transactions have been
sent by the DDP server (bank), DDP
will send a special message called
ready. The ready message indicates
that all the initial data for the
subscription has been sent and you
are good to go.
4. Some time later, after arunoda has
sent his transfer, sacha will receive
the transaction as another added
notification.
16. One Language
Meteor lets you write both the client and the
server parts of your application in JavaScript.
20. Database Everywhere
You can use the same methods to access your
database from the client or the server.
● MongoDB on the server
● Minimongo in the browser
● Meteor keeps it all in sync
21. Mini Databases
● The minimongo package is a reimplementation of
(almost) the entire MongoDB API, against an in-
memory JavaScript database.
● It is like a MongoDB emulator that runs inside your web
browser. You can insert data into it and search, sort,
and update that data.
https://www.meteor.com/mini-databases
22. Latency Compensation
On the client, Meteor prefetches data and
simulates models to make it look like server
method calls return instantly.
23. Latency Compensation
In a traditional
application, when a
user does some
action on an app,
they have to wait
until the request is
processed on the
server before the
changes are
reflected by the UI.
24. Latency Compensation
But with latency
compensation, users
no longer need to
wait. The result of
an action is
reflected by the
browser
immediately. This is
a built-in feature of
Meteor and you can
use it very easily.
25. Implementing latency compensation
● Latency compensation works only for write operations to a data store
supported by Meteor (currently only MongoDB and Redis).
● For Third-party service like Twitter, there is no way to implement
latency compensation directly.
● There are only two places where you can do a write operation to a data
store: inside a method call or directly via a local collection.
26. Full Stack Reactivity
In Meteor, realtime is the
default. All layers, from
database to template,
update themselves
automatically when
necessary.
● Client UI and database
are updated 1st
● Change sent to server
● Issues are resolved after
the fact
28. Simplicity = Productivity.
The best way to make something seem simple
is to have it actually be simple. Meteor's main
functionality has clean, classically beautiful
APIs.
30. App - Topic Bank
Topic Name Suggested By Vote Action
Dart Fyaz 10
Meteor Tahmina 12
Up Down
Up Down
Topic Bank
31. Let’s Get Started!
curl https://install.meteor.com/ | sh
Installing Meteor
Creating an app
meteor create hotTopics
cd hotTopics
meteor
Run app
32. Project Structure
lib/ # <- any common code for client/server.
lib/config.js # <- general configuration
lib/methods.js # <- Meteor.method definitions
lib/external # <- common code from someone else
## Note that js files in lib folders are loaded before other js files.
collections/ # <- definitions of collections and methods on them (could be models/)
client/lib # <- client specific libraries (also loaded first)
client/lib/config.js # <- configuration of any client side packages
client/lib/helpers # <- any helpers (handlebars or otherwise) that are used often in view files
client/main.js # <- subscriptions, basic Meteor.startup code.
client/index.html # <- toplevel html
client/index.js # <- and its JS
client/views/<page>.html # <- the templates specific to a single page
client/views/<page>.js # <- and the JS to hook it up
client/views/<type>/ # <- if you find you have a lot of views of the same object type
server/publications.js # <- Meteor.publish definitions
server/lib/config.js # <- configuration of server side packages
33. The JavaScript and CSS files in an application are loaded according to these
rules:
● Files in subdirectories are loaded before files in parent directories, so
that files in the deepest subdirectory are loaded first, and files in the
root directory are loaded last.
● Within a directory, files are loaded in alphabetical order by filename.
● After sorting as described above, all files under directories named lib are
moved before everything else (preserving their order).
● Finally, all files that match main.* are moved after everything else
(preserving their order).
CSS and Javascript Files Ordering
34. Meteor parses all of the HTML files in app folder and identifies three top-level
tags:
● <head>
● <body>
● <template>
Default Template Engine: Blaze
Can be replaced with any other template engine.
Create html view
36. Include package
Meteor Package manager: ATMOSPHERE
meteor add mizzao:bootstrap-3
Add Package in project (example: bootstrap-3)
meteor list
List all installed packages