Skip to content

Instantly share code, notes, and snippets.

var React = require('react/addons');
var ReactIgnore = {
displayName: 'ReactIgnore',
shouldComponentUpdate (){
return false;
},
render (){
return React.Children.only(this.props.children);
}

From Meteor's documentation:

In Meteor, your server code runs in a single thread per request, not in the asynchronous callback style typical of Node. We find the linear execution model a better fit for the typical server code in a Meteor application.

This guide serves as a mini-tour of tools, trix and patterns that can be used to run async code in Meteor.

Basic async

Sometimes we need to run async code in Meteor.methods. For this we create a Future to block until the async code has finished. This pattern can be seen all over Meteor's own codebase:

var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var assert = require('assert')
console.log('\n===========');
console.log(' mongoose version: %s', mongoose.version);
console.log('========\n\n');
var dbname = 'testing_geojsonPoint';
var ngAppElem = angular.element(document.querySelector('[ng-app]') || document);
window.injector = ngAppElem.injector();
window.inject = injector.invoke;
window.$rootScope = ngAppElem.scope();
Object.defineProperty(window, '$scope', {
get: function () {
var elem = angular.element(__commandLineAPI.$0);
return elem.isolateScope() || elem.scope();
controllers.controller('MainCtrl', function($scope, $location, Facebook, $rootScope, $http, $location, Upload, Auth, User, Question, Category, Serie, Record, Location, Popup, Process, Card, Question) {
$scope.$on('authLoaded', function() {
$scope.isExpert($scope.main.serieId);
$scope.isMember($scope.main.serieId);
});
$scope.loadAuth = function() {
Auth.load().success(function(data) {
$scope.main.user = data.user;
$scope.$broadcast("authLoaded");
// Module dependencies
var express = require('express'),
mysql = require('mysql');
// Application initialization
var connection = mysql.createConnection({
host : 'localhost',
user : 'root',

Keybase proof

I hereby claim:

  • I am curioussavage on github.
  • I am curioussavage (https://keybase.io/curioussavage) on keybase.
  • I have a public key whose fingerprint is F505 28D8 5AE4 4C8D 4A46 1C62 442C CC04 3FB0 0ABA

To claim this, I am signing this object: