3. So, what is Meteor?
Meteor is an ultra-simple environment for building modern websites
Meteor is two things:
A library of packages: pre-written, self-contained modules that you might need in your app
A command-line tool called meteor
4. Principles of Meteor
Data on the Wire
One Language
Database Everywhere
Latency Compensation
Full Stack Reactivity
Embrace the Ecosystem
Simplicity Equals Productivity
5. Structuring your application
Free to play :)
But few rules for file loading:
• HTML template files are always loaded before everything else
• Files beginning with main. are loaded last
• Files inside any lib/ directory are loaded next
• Files with deeper paths are loaded next
• Files are then loaded in alphabetical order of the entire path
7. Meteor makes writing distributed client code as simple as talking to a local database
The client and server share the same database API
Most Meteor apps use MongoDB
But, they working on support on other DB as well:
Meteor Livequery
8. // declare collections
// this code should be included in both the client and the server
Parties = new Mongo.Collection("parties");
// server: populate collections with some initial documents
Parties.insert({name: "Super Bowl Party"});
// server: publish the set of parties the logged-in user can see.
Meteor.publish("parties", function () {
return Parties.find({$or: [{"public": true},
{invited: this.userId},
{owner: this.userId}]});
});
// client: start a parties subscription
Meteor.subscribe("parties");
// client: return array of Parties this client can read
return Parties.find().fetch(); // synchronous!
MongoDB
9. Security
// server: don't allow client to insert a party
Parties.allow({
insert: function (userId, party) {
return false;
}
});
// client: this will fail
var party = { ... };
Parties.insert(party);
10. Reactivity
Meteor's implementation is a package called Tracker
Tracker.autorun(function () {
Meteor.subscribe("messages", Session.get("currentRoomId"));
});
11. Distributed Data Protocol
Simple protocol for fetching structured data from a server, and receiving live updates when that data changes.
DDP implementations
Android
AS3 (ActionScript3)
C#
Dart
Go
Haskell
iOS
Java
JavaScript
.NET
Node.JS
Objective C (iOS)
PHP
Python
Qt / QML
Ruby
16. But Blaze is just one module that we can easily replace with another
AngularJs
17. Why Meteor?
• Best or one of the best :) real time backend for AngularJS
• Super easy, Real-time integration with the database
• Full stack and open source
• Great Cordova integration
• Easy deployment
18. Why use AngularJS?
• MVC and MVVM structure on the client
• Use existing applications
• Ecosystem and community
• Easy entrance to Meteor
• Angular 2.0
19. Don’t choose one solution
Use both Blaze and AngularJS
Use libraries, packages and solutions from both communities
Give neutral perspective on the two frameworks
20. So, what it gives you
Real Time Data Sync and Store
$meteor.collection(collection, autobind)
21. User authentication
List of helpers that allows you integrate your code with meteor accounts
1 $stateProvider
2 .state('home', {
3 url: '/',
4 templateUrl: 'client/views/home.ng.html',
5 controller: 'HomeController'
6 resolve: {
7 "currentUser": ["$meteor", function($meteor){
8 return $meteor.requireUser();
9 }]
10 }
11 });
Principles of Meteor
Data on the Wire. Meteor doesn't send HTML over the network. The server sends data and lets the client render it.
One Language. Meteor lets you write both the client and the server parts of your application in JavaScript.
Database Everywhere. You can use the same methods to access your database from the client or the server.
Latency Compensation. On the client, Meteor prefetches data and simulates models to make it look like server method calls return instantly.
Full Stack Reactivity. In Meteor, realtime is the default. All layers, from database to template, update themselves automatically when necessary.
Embrace the Ecosystem. Meteor is open source and integrates with existing open source tools and frameworks.
Simplicity Equals 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.
Meteor Livequery is a family of live database connectors
These connectors let you perform "live queries" against your favorite database:
The need for Livequery
In any modern app — any app without a refresh button, as RethinkDB and Firebase do similar
How it works
How Livequery detects changes
database triggers
replication log
to poll the database for changes
In Meteor, the client and server share the same database API. The same exact application code — like validators and computed properties — can often run in both places. But while code running on the server has direct access to the database, code running on the client does not. This distinction is the basis for Meteor's data security model.
When the client changes one or more documents, it sends a message to the server requesting the change. The server checks the proposed change against a set of allow/deny rules you write as JavaScript functions. The server only accepts the change if all the rules pass.
Meteor has a cute trick, though. When a client issues a write to the server, it also updates its local cache immediately, without waiting for the server's response. This means the screen will redraw right away.
This example (taken from a chat room client) sets up a data subscription based on the session variable currentRoomId. If the value of Session.get("currentRoomId") changes for any reason, the function will be automatically re-run, setting up a new subscription that replaces the old one.
Meteor includes Meteor Accounts, a state-of-the-art authentication system. It features secure password login using the bcrypt algorithm, and integration with external services including Facebook, GitHub, Google, Meetup, Twitter, and Weibo.
METEOR TOOL
The Meteor tool is an integrated command-line interface for building, packaging and deploying apps with Meteor.
mobile, web,
Can contain plugins that extend Isobuild
DEVELOPER ACCOUNTS
Meteor developer accounts provide a single username to identify you across the Meteor community for publishing packages, deploying apps and logging into services.
ATMOSPHERE
Atmosphere provides a user interface over the Meteor package server enabling you to discover and use community packages in your app.
The Meteor Galaxy service is the best way to operate and scale 'Connected Client' apps built with Meteor. Galaxy provides a great experience to simplify DevOps for apps.
Sync data in realtime across your own server, DB and clients instantly.
Now we need to tell angular-meteor to expose this service as an API to our client. We do that using the ServerAPIProvider. Using this provider we register our service as an API
An important note is that if the service that was registered as an API is in common code (also defined on the client) the call to the service function will call the client function and the server function both using the client function as a stub. That is the same expected result when using a Meteor.method.
Use Angular 2.0 syntax with ES6 on top of your Angular 1.x application. Angular 2 Now is a library by @pbastowski that is targeted at people who:
- use Angular 1.x and think about migrating to Angular 2 when it finally arrives.
like Angular 2 features and want to start using them on top of Angular 1.x right now.
Angular 2.0.0-alpha
An angular2-meteor package with all the dependencies (TypeScript, System.js, etc...) so you can start writing Angular 2.0 code right away. written by - @barbatus, @netanelgilad and @ShMcK.
http://angular-meteor.com/angular2