How does the messages-count example in Meteor docs work?

Thanks for prompting me to write a clearer explanation. Here’s a fuller example with my comments. There were a few bugs and inconsistencies that I’ve cleaned up. Next docs release will use this. Meteor.publish is quite flexible. It’s not limited to publishing existing MongoDB collections to the client: we can publish anything we want. Specifically, … Read more

Ordering of the css and js files loaded by Meteor

This question has since been answered in http://docs.meteor.com/ The JavaScript and CSS files in an application are loaded according to these rules: Files in the lib directory at the root of your application are loaded first. Files that match main.* are loaded after everything else. Files in subdirectories are loaded before files in parent directories, … Read more

The context of “this” in Meteor template event handlers (using Handlebars for templating)

This video explains the concepts: http://www.eventedmind.com/posts/meteor-spark-data-annotation-and-data-contexts. The direct answer to your question: The thisArg inside an event handler should point to a data context. But sometimes the data context is undefined. When you use the Function.prototype.call(thisArg, …) in JavaScript, if the thisArg is undefined (e.g. a dataContext is undefined) the browser will set this equal … Read more

How to build a Meteor smart package

Meteor now supports a create –package command. See the meteor docs. Example (substitute your own meteor developer account for “cunneen”): meteor create –package cunneen:foo Output: cunneen:foo: created in your app Results: packages/cunneen:foo/package.js Package.describe({ name: ‘cunneen:foo’, version: ‘0.0.1’, // Brief, one-line summary of the package. summary: ”, // URL to the Git repository containing the source … Read more

BABEL Note: The code generator has deoptimised the styling of “app.js” as it exceeds the max of “100KB in Meteor

This is not a real issue. Just a warning. When babel compiles some code, it try to offer a readable output, but when files become big (>100KB), babel considers (by default) that it’s not useful to keep this option enabled (because yes it’s an option, see https://stackoverflow.com/a/30879872/988941 for more information). It’s not a problem to … Read more

How do I delete or remove Session variables?

[note: this answer is for Meteor 0.6.6.2 through at least 1.1.0.2] [edit: updated to also explain how to do this while not breaking reactivity. Thanks to @DeanRadcliffe, @AdnanY, @TomWijsman, and @MikeGraf !] The data is stored inside Session.keys, which is simply an object, so you can manually delete keys: Session.set(‘foo’, ‘bar’) delete Session.keys[‘foo’] console.log(Session.get(‘foo’)) // … Read more

Accessing Meteor production database

You should use meteor mongo http://blah.meteor.com; or even shorter meteor mongo blah.meteor.com. For documentation you can run meteor help mongo. Extract from running the help command above: Instead of opening a shell, specifying –url (-U) will return a URL suitable for an external program to connect to the database. For remote databases on deployed applications, … Read more