SlideShare a Scribd company logo
@MALAGANT 
WWW.RAILS-EXPERTS.COM 
SINGLE UND TROTZDEM GLÜCKLICH 
- EINE EINFÜHRUNG IN METEOR
WAS IST METEOR?
SINGLE PAGE APPS MIT 
JAVASCRIPT
PRINZIPIEN 
• Client renderd HTML 
• Datenaustausch DDP 
• Javascript für alles (Client, 
Server, Datenbank) 
• Latency Compensation 
• Reactive Apps 
• MongoDB
CURL HTTPS:// 
INSTALL.METEOR.COM/ | SH
DEMO: TODOLISTE
APP GENERIEREN 
• meteor create todos 
• cd todos 
• meteor
VIEWS MIT SPACEBARS 
TEMPLATES = HTML + SPACEBARS 
<head> 
<title>Todo List</title> 
</head> 
<body> 
<div class="container"> 
<header> 
<h1>Todo List</h1> 
</header> 
<ul> 
{{#each tasks}} 
{{> task}} 
{{/each}} 
</ul> 
</div> 
</body> 
<template name="task"> 
<li>{{text}}</li> 
</template>
JAVASCRIPT 
if (Meteor.isClient) { 
// This code only runs on the client 
Template.body.helpers({ 
tasks: [ 
{ text: "Aufstehen" }, 
{ text: "Zähneputzen" }, 
{ text: "Duschen" } 
] 
}); 
}
HTML DATEIEN 
DEFINIEREN TEMPLATES
TODOS IN COLLECTIONS 
Tasks = new Mongo.Collection("tasks"); 
if (Meteor.isClient) { 
// This code only runs on the client 
Template.body.helpers({ 
tasks: function () { 
return Tasks.find({}); 
} 
}); 
}
MONGO CONSOLE 
db.tasks.insert({ 
text: "Hello world!", 
createdAt: new Date() 
});
EINGABEFORMULAR HINZUFÜGEN 
<form class="new-task"> 
<input type="text" 
name="text" 
placeholder="Type to add new tasks" /> 
</form>
EVENTS 
Template.body.events({ 
"submit .new-task": function (event) { 
var text = event.target.text.value; 
Tasks.insert({ 
text: text, 
createdAt: new Date() // current time 
}); 
// Clear form 
event.target.text.value = ""; 
// Prevent default form submit 
return false; 
} 
});
SORTIEREN 
Template.body.helpers({ 
tasks: function () { 
return Tasks.find({}, {sort: { createdAt: -1}}); 
} 
});
LÖSCHEN UND ERLEDIGEN VON TASKS 
<template name="task"> 
<li class="{{#if checked}}checked{{/if}}"> 
<button class="delete">&times;</button> 
<input type="checkbox" 
checked="{{checked}}" 
class="toggle-checked" /> 
<span class="text">{{text}}</span> 
</li> 
</template>
LÖSCHEN UND ERLEDIGEN VON TASKS 
Template.task.events({ 
"click .toggle-checked": function () { 
Tasks.update(this._id, {$set: {checked: ! 
this.checked}}); 
}, 
"click .delete": function () { 
Tasks.remove(this._id); 
} 
});
DEPLOYMENT AUF METEOR.COM 
• meteor deploy todo-wjax2014.meteor.com
MOBILE: ANDROID 
$ meteor install-sdk android 
$ meteor add-platform android 
$ meteor run android
MOBILE: IOS 
$ meteor install-sdk ios 
$ meteor add-platform ios 
$ meteor run ios
SESSION DATA FÜR DAS UI 
<label class="hide-completed"> 
<input type="checkbox" 
checked="{{hideCompleted}}" /> 
Hide Completed Tasks 
</label>
EVENTHANDLING 
"change .hide-completed input": function (event) { 
Session.set("hideCompleted", event.target.checked); 
}
UPDATE DER HELPER 
Template.body.helpers({ 
tasks: function () { 
if (Session.get("hideCompleted")) { 
// If hide completed is checked, filter tasks 
return Tasks.find({checked: {$ne: true}}, {sort: {createdAt: -1}}); 
} else { 
// Otherwise, return all of the tasks 
return Tasks.find({}, {sort: {createdAt: -1}}); 
} 
}, 
hideCompleted: function () { 
return Session.get("hideCompleted"); 
} 
});
INCOMPLETE INDICATOR 
incompleteCount: function () { 
return Tasks.find({checked: {$ne: true}}).count(); 
} 
<h1>Todo List ({{incompleteCount}})</h1>
LATENCY COMPENSATION 
• Meteor schickt Daten an MongoDB 
• Client geht davon aus, dass alles ok ist und zeigt das 
Ergebnis vorher schon an.
RAN AN DEN SPECK
RESSOURCEN 
• https://www.discovermeteor.com/ 
• https://www.meteor.com/ 
• https://www.yauh.de/articles/376/best-learning-resources- 
for-meteorjs/
FRAGEN UND ANTWORTEN

More Related Content

PDF
Device Orientation & WebSocket API
KEY
JavaScript Dynamic Loading
PDF
ECMA2015 INSIDE
DOCX
PROYECTO PRUEBA DE CONEXIONES (Mantenimiento)
PDF
DOCX
Ejercicio progra
PDF
Angular 2 не так уж и плох... А если задуматься, то и просто хорош / Алексей ...
PPTX
React - podsumowanie z placu boju
Device Orientation & WebSocket API
JavaScript Dynamic Loading
ECMA2015 INSIDE
PROYECTO PRUEBA DE CONEXIONES (Mantenimiento)
Ejercicio progra
Angular 2 не так уж и плох... А если задуматься, то и просто хорош / Алексей ...
React - podsumowanie z placu boju

What's hot (10)

PPTX
9. CodeIgniter add
DOC
Mantto con vb2010
DOCX
Validaformulariojs
PDF
An introduction to Ember framework
PDF
jQuery sans jQuery
PDF
Proyecto Final Android-SQLite
PPTX
7. CodeIgniter move1
PPTX
8. CodeIgniter move2
PPT
Tools20121015
9. CodeIgniter add
Mantto con vb2010
Validaformulariojs
An introduction to Ember framework
jQuery sans jQuery
Proyecto Final Android-SQLite
7. CodeIgniter move1
8. CodeIgniter move2
Tools20121015
Ad

Viewers also liked (20)

PPT
Thesis 1 4
PPTX
Climate Change and the 5 rules of the environment
PDF
Apostila massa folhada_v3_aprovado
PPT
Uncovering Windows - Silverlight Seminar
PPTX
1st week middle school life science course intro
PPT
LWB486 Week 7 Copyright
PDF
Compa 2009 Giurus
PPTX
Noblisse Oblige
PPTX
S3P Class Environment presentation
PDF
APIdays 2015 - The State of Web API Languages
PPT
Industrialization Powerpoint
PPT
22 28
PPT
Vertsol Theses Powerpoint Slides
PPT
Vertsol Theses3 Powerpoint Slides
PPT
Thesis 15 - 21
PDF
Smart citizenship through data context
PPTX
Seri Sejarah Ekonomi Islam: faktor faktor yang mempengaruhi pemikiran ekonomi...
PDF
20140527 - APIcon SF - Workshop #2 - Document and manage Java-based web APIs
ODP
Email Delivery Support
PPT
Visual Public Communication And Art
Thesis 1 4
Climate Change and the 5 rules of the environment
Apostila massa folhada_v3_aprovado
Uncovering Windows - Silverlight Seminar
1st week middle school life science course intro
LWB486 Week 7 Copyright
Compa 2009 Giurus
Noblisse Oblige
S3P Class Environment presentation
APIdays 2015 - The State of Web API Languages
Industrialization Powerpoint
22 28
Vertsol Theses Powerpoint Slides
Vertsol Theses3 Powerpoint Slides
Thesis 15 - 21
Smart citizenship through data context
Seri Sejarah Ekonomi Islam: faktor faktor yang mempengaruhi pemikiran ekonomi...
20140527 - APIcon SF - Workshop #2 - Document and manage Java-based web APIs
Email Delivery Support
Visual Public Communication And Art
Ad

Einführung in Meteor