introduction to meteor at chadev lunch

17
Introduction to MeteorJS by Andrew McPherson

Upload: andrew-mcpherson

Post on 10-May-2015

151 views

Category:

Technology


1 download

DESCRIPTION

An introduction to Meteor, the javascript framework for efficiently deploying your applications, as given at the Chattanooga Developer's Lunch on July 3rd, 2014. During the presentation, I try to put together a clone demo of GoogleDocs to exhibit the capabilities of Meteor!

TRANSCRIPT

Page 1: Introduction to Meteor at ChaDev Lunch

Introduction to MeteorJSby Andrew McPherson

Page 2: Introduction to Meteor at ChaDev Lunch

a bit about me.

Andrew McPherson I like videogames.

1. Aspiring developer and entrepreneur.2. Born and raised here in Chattanooga.3. Student of computer science at UTC.

github.com/arcymtwitter.com/andrewmcp333

I once had a beard.

Page 3: Introduction to Meteor at ChaDev Lunch

My current project is“the online video editor”

● Originally it was built through a lot of NodeJS with MongoDB and SocketIO.

● But I had a lot of issues in maintaining consistency of data between clients.

● Then I stumbled upon MeteorJS!

a bit about my projects.

Page 4: Introduction to Meteor at ChaDev Lunch

a bit about meteor.

Meteor is a javascript framework that offers...

● client data synchronization.● reactive updating templates.● external module interoperability.● just really simple syntax.

It doesn’t want to replace existing frameworks, but integrate upon them.

Page 5: Introduction to Meteor at ChaDev Lunch

Want to see a bit of syntax?

Page 6: Introduction to Meteor at ChaDev Lunch

Starting the project

To initialize...meteor create NoogaDocs

> NoogaDocs created!

cd NoogaDocs

ls

> .meteor

> NoogaDocs.css

> NoogaDocs.html

> NoogaDocs.js

To execute...meteor

> Started proxy.

> Started database.

> Started application.

> App at 127.0.0.1:3000

Page 7: Introduction to Meteor at ChaDev Lunch

In the .html<head>

<title>NoogDocs</title>

</head>

<body>

<div id=“greeting”>

Hello, {{name}}!

</div>

</body>

In the .jsif(Meteor.isClient)

{

Template.name = “World”;

}

In the .css#greeting

{

font-weight: bold;

}

Trying it out

Page 8: Introduction to Meteor at ChaDev Lunch

In the .jsif(Meteor.isClient)

{

var who = “World”

Template.greet.name = who

}

In the .html<template name=“greet”>

<div id=“greeting”>

Hello, {{name}}!

</div>

</template>

<body>

{{> greet}}

</body>

Defining a template

Page 9: Introduction to Meteor at ChaDev Lunch

In the .jsif(Meteor.isClient)

{

Template.greet.name = function()

{

var who = “World”;

return who;

}

//this is just another way of doing it.

}

Using more functions

Page 10: Introduction to Meteor at ChaDev Lunch

In the .jsif(Meteor.isClient)

{

Template.greet.name = function()

{

var who = this || “World”;

return who;

}

}

In the .html{{> greet “Andrew”}}

{{> greet “Anthny”}}

{{> greet “Adam”}}

Accessing the data

Page 11: Introduction to Meteor at ChaDev Lunch

In the .jsTemplate.list.persons = [

{name: “Andrew”},

{name: “Anthony”},

{name: “Adam”}

];

In the .html<template name=“list”>

<ul>

{{#each persons}}

<li>{{name}}</li>

{{/each}}

</ul>

</template>

<body>

{{> list}}

</body>

Iterating via helpers

Page 12: Introduction to Meteor at ChaDev Lunch

In the .jsvar Persons = new Meteor.Collection(“persons”);

if(Meteor.isClient){ Template.list.persons = Persons.find({});}

if(Meteor.isServer){

Persons.insert({name: “Andrew”});Persons.insert({name: “Anthony”});Persons.insert({name: “Adam”});

}

Including a database

Page 13: Introduction to Meteor at ChaDev Lunch

Binding to events

In the .jsvar Persons = new Meteor.Collection(“persons”);

if(Meteor.isClient){ Template.list.persons = Persons.find({}); Template.list.events = { “click li”: function() { Persons.remove(this._id); } }}

Page 14: Introduction to Meteor at ChaDev Lunch

So let’s try a live demo!Hopefully I won’t mess this up! (May the programming gods have mercy on my soul)

Page 15: Introduction to Meteor at ChaDev Lunch

some issues with meteor

● potential networking latency● best for single page apps● still in development :\● ● ●● not much else than that.

Page 16: Introduction to Meteor at ChaDev Lunch

some resources for meteor

Meteor Documentation: docs.meteor.com

Meteor Examples: meteor.com/learn-meteor

NoogaDocs Github: github.com/arcym/noogadocs

“Useful Meteor Resources”discovermeteor.com/blog/useful-meteor-resources

“How to learn Javascript properly”javascriptissexy.com/how-to-learn-javascript-properly

Page 17: Introduction to Meteor at ChaDev Lunch

Thank you so much!