Save 10% off ANY FITC event with discount code 'slideshare'
See our upcoming events at www.fitc.ca
OVERVIEW
Meteor allows you to quickly create new web applications. Using a single code base for the client and the server, no-sql mongo, template-oriented UX organization and painless deployment, designing and developing with Meteor is fun. But the real game changer is Reactivity.
Reactivity is made up of two parts – data sources and computations. When you build a page, Meteor remembers the computations that use reactive data sources. Then, when a data in a reactive source changes, the computations that depend on the data are invalidated and re-run – which can re-render the affected parts of your application. The true beauty of it is that it’s all automatic. You don’t need to write any code to watch for changes – Meteor does all that for you.
Learning to build web applications in the Reactive Style gives you more time to concentrate on UX than traditional web development. Being able to side-step much of the application setup and data management frees you to focus on providing a pleasurable experience as well as useful functionality.
2. What’s Meteor about?
“A better way to build apps.”
“Meteor is an open source platform
for building top-quality web apps
in a fraction of the time,
whether you’re an expert developer
or just getting started.”
ally?
Re
18. How We Must Code
Nine months ago you wrote some code...
19. How We Must Code
Today you have to find and change it...
20. Follow the Breadcrumbs...
from the app in the browser
...to a search of the code base
...to the app inspector...
...repeatedly
21. Searching for Code, Traditionally
• look for element by CSS selector
• look for action bound to element
• look for code that emits element
• look for code that changes CSS selector
• keep looking inward...
22. Changing Code, Traditionally
• Change all the places!
• Test like the Dickens!
• ummm...
did you really change all the places?
23. Searching for Code in Meteor
• look for the template that emits the element
• examine its html, css and javascript
24. Changing Code in Meteor
• Change the code in the template
• Test the changes (tinytest, laika, …)
25. ‘Extra’ Coding
This one is hard to quantify.
HTML with handlebar templates
JavaScript / CoffeeScript
CSS / SCSS
packages
the code needed to build
a Meteor-based web UX
is the most straightforward I’ve found.
YMMV
26. Conventional Flow
Code uses the current values when called.
If a is 5 and b is 3, then
c = a+b
would set c to 8.
Later, if a became 4 and b became 2,
then c would still be 8 - until the code
was called again.
27. Reactive Flow
Code uses values as they change.
If a is 5 and b is 3, then
c = a+b
would set c to 8.
Later, if a became 4 and b became 2,
then c would become 6 automatically.
28. Reactive Style Programming
is about writing code that
renders values when they are delivered
not code that
retrieves values so they can be rendered.
Data is pushed, not pulled.
43. In the frameworks you’re probably used to,
a web application is coded Imperatively.
In Meteor using its Reactive framework,
a web application is coded Declaratively.
44. Imperative Coding
if you’re lucky enough to have database notification
through an observe-like function,
you implement callbacks
Items.find().observe!
added: (item) ->!
$('ul').append '<li id="'+item._id+'">'+!
item.name+'</li>'!
changed: (item) ->!
$('ul li#'+item._id).text item.name!
removed: (item) -> !
$('ul li#'+item._id).detach()
45. Declarative Coding
Meteor does the observe callback behind the scenes
<template name="itemList">!
<ul>!
{{#each items}}!
<li>{{name}}</li>!
{{/each}}!
</ul>!
</template>
Template.itemList.helpers!
items: -> Items.find()
50. Why Computations?
Because Meteor has the potential to
change the entire interface
when a reactive source changes!
Changes based on a computation becoming invalid
focus on only the parts of the interface
that depend on the computation.
57. What are Reactive Sources?
remote
local (client)
database queries
(subscriptions)
session variables
status
user / user id
logging in
subscription ready
63. An Example:
Injectives
Sessions variables are reactive sources
global to the client.
An Injective is a local reactive source that
can be more closely scoped to the
functions and objects that uses it.
65. Consider the use of the an injective:
Foo.innerWidth =!
Deps.injective window.innerWidth
Any computation that calls
Foo.innerWidth.get( ) will react when
its value changes.
So then,
$(window).resize ->!
Foo.innerWidth.set window.innerWidth
66. Example of Injectives
Use the height and width of a browser window
to control the size of some objects.
innerWidth = Deps.injective window.innerWidth!
innerHeight = Deps.injective window.innerHeight!
!
$(window).resize ->!
innerWidth.set window.innerWidth!
innerHeight.set window.innerHeight!
!
Template.box.helpers!
size: ->!
Math.floor (innerWidth.get()+innerHeight.get())/4.0
67. So why should
Meteor and Reactivity
Narrower technology stack
•
matter to change
• Easier to find and me? code
•
•
Less extra coding
Changes are pushed, not pulled