Michel Herszak
Freelance Web Developer from #YEG
Michel Herszak
I am a freelance web developer from Canada. I specialize in Meteor with React projects, and I like to build using Microservices and smart packages.
Twitter: @MHerszak; Web:Base2Industries; email: michel.herszak@gmail.com.
The biggest advantage with Meteor has been the ability to reuse a lot of code, especially with mobile applications.
Ahmed Hassan, Co-founder Flowkey
I would say building with Meteor it took half the time and half the people.
Stuart Mitchell, Product Director @ Verso
We wanted to develop this app in a short amount of time and Meteor allowed us to share as much code as possible between all platforms, giving us higher velocity and a smaller codebase.
Hans Andersson, Chief Development Officer and Co-founder Hansoft
Meteor simplifies everything so much, that iterating and adding a new feature takes a week.
Tigran Sloyan, CEO CodeFights
Easy installation process
curl https://install.meteor.com/ | sh
Great community and lots of recourses
https://www.meteor.com/tools/resources
Start a project simply by typing
meteor create myNewProject || meteor create --example localmarket
Meteor Speaker Kit
What do you get when you work with Meteor
Multiplatform support
Install to deploy with payed/free hosting
Hot code push
Full-stack smart packages
Meteor from the command line
Meteor Speaker Kit
This is what Meteor ships with
This is your job
It's called a platform because it encompasses everything you need to go from nothing to a complete web app using one language..
Meteor is a platform not a framework
HTML
Templates
APP Logic
Reactive UI update system
Native mobile scanner
Optimistic client side updates
Client-side data storage
Custom data-sync protocol
Realtime database modeling
Build & Update system
Microservices
Database
What now?
LiveQuery is really the feature that sets Meteor apart, but it doesn't scale well.
Always have the right requirements when you decide to use Meteor
Do not necessarily use Meteor for a Blog...
Do you need reactivity?
Meteor is not like Ruby on Rails, Express, PHP
What does that mean for Meteor?
Guess what, that problem is currently pretty real for the community but it hasn't been solved yet. It can be solved with some hacks.
Any solution?
Index your MongoDB
Planning on a large application?
Other issues related to Meteor, some of them are no problem at all.
When your app isn't a single page anymore
Now, how about #anchor fragments?
Router Package anywhere, but which is the right one?
Could potentially re-render entire sections of your app
Increase in required boilerplate code but a better control on a template level
Meteor let's you structure your app pretty much any way you want, with special treatment of client/server
When Meteor becomes unmanageable
Reusability?
Predictability?
Maintainability?
When Meteor becomes unmanageable
When Meteor becomes unmanageable
Reusability!
Predictability!
Maintainability!
Namespacing
Loosely coupled
When Meteor becomes unmanageable
MVVM-styled behaviour can be achieved using get from aldeed:template-extension with events still bubbling in Blaze
Always know your Data content
Meteor is great #with #each data context, use it.
<template name="profile">
{{#with profile}}
<img src="{{avatar}}"/>
<p>{{name}}</p>
{{/with}}
</template>
<template name="profile">
{{#with profile}}
{{>avatar}}
{{/with}}
</template>
<template name="profiles">
{{#each profile}}
{{>avatar}}
{{/each}}
</template>
Denormalise your DB collections
DB space is cheap, data on the wire isn't!
Reviews = new Mongo.Collection('reviews');
function addOtherData(userId, book) {
var book = Books.findOne(review.movieId),
user = Meteor.users.findOne(review.userId);
// add other denormalised data here
review.username = user && user.username;
review.bookGenre = book && book.genre;
}
Write functions that propagate changes to all collections.
MongoDB is NoSQL
MongoDB is great, but it doesn't support joint.
Note.findOne().related(‘personId’).related(‘notes’);
MongoDB is NoSQL
MongoDB doesn't need schemas to work, please use Schema.
User data is important (security measures)
Use your users ID a lot, but don't send it over the wire!
/**
* Stores a message from a user to service.
* @param obj
* @returns {*}
* @constructor
*/
"APP/Message/SaveToDB":(obj)=>
{
let noServices = _.pluck(obj,"services"),
/**
* Build message object
*/
message = _.extend({},noServices,{
/**
* Current users userId
*/
userId:Meteor.userId(),
/**
* The service this message was send to
*/
services:returnService(obj),
ReactiveVar & Sessions
Meteor ReactiveVar is great, don't use Sessions for global states - there are different methods for reactive data.
Make use of smart packages but do your research
AtmosphereJS is great, but be aware of 3rd party packages! Here are the once I am still using.
I love Meteor... BUT..
Start a Meteor project today and get things done quickly, but don't expect maintainable code.
Get started with 3rd party packages, but don't expect support in case it breaks.
Expect a paradigm change, React is heavily discussed and Blaze2 might just be a wrapper around it. Or the other way around :)
These companies love it, too
I am a freelance web developer from Canada. I specialize in Meteor with React projects, and I like to build using Microservices and smart packages.
Twitter: @MHerszak; Web:Base2Industries; email: michel.herszak@gmail.com.
By Michel Herszak
This deck of slides is an accumulation of best practices with Meteor that I have found and experienced of the past 2.5 years I worked with Meteor.