Writing Packages

After reading this article, you’ll know: When to create an npm package and when to create an Atmosphere package The basics of writing an npm package The basics of writing an Atmosphere package How to depend on other packages, both from Atmosphere and npm How an Atmosphere package can integrate with Meteor’s build system The Meteor platform supports two package systems: npm, a repository of JavaScript modules for Node.js and the browser, and Atmosphere, a repository of packages written specifi

meteor publish

meteor publish Publishes your package. To publish, you must cd into the package directory, log in with your Meteor Developer Account and run meteor publish. By convention, published package names must begin with the maintainer's Meteor Developer Account username and a colon, like so: iron:router. To publish a package for the first time, use meteor publish --create. Sometimes packages may contain binary code specific to an architecture (for example, they may use an npm package). In that case, ru

Selectors

Mongo-Style Selectors The simplest selectors are just a string or Mongo.ObjectID. These selectors match the document with that value in its _id field. A slightly more complex form of selector is an object containing a set of keys that must match in a document: // Matches all documents where deleted is false {deleted: false} // Matches all documents where the name and cognomen are as given {name: "Rhialto", cognomen: "the Marvelous"} // Matches every document {} But they can also contain mo

Blaze.View

Client new Blaze.View([name], renderFunction) import { Blaze } from 'meteor/blaze' Source Constructor for a View, which represents a reactive region of DOM. Arguments name String Optional. A name for this type of View. See view.name. renderFunction Function A function that returns renderable content. In this function, this is bound to the View.

Session.get

Client Session.get(key) import { Session } from 'meteor/session' Source Get the value of a session variable. If inside a reactive computation, invalidate the computation the next time the value of the variable is changed by Session.set. This returns a clone of the session value, so if it's an object or an array, mutating the returned value has no effect on the value stored in the session. Arguments key String The name of the session variable to return

EJSON.addType

Anywhere EJSON.addType(name, factory) import { EJSON } from 'meteor/ejson' Source Add a custom datatype to EJSON. Arguments name String A tag for your custom type; must be unique among custom data types defined in your project, and must match the result of your type's typeName method. factory Function A function that deserializes a JSON-compatible value into an instance of your type. This should match the serialization performed by your type's toJSONValue method.

this.userId

Server this.userId Source Access inside the publish function. The id of the logged-in user, or null if no user is logged in.

Session.equals

Client Session.equals(key, value) import { Session } from 'meteor/session' Source Test if a session variable is equal to a value. If inside a reactive computation, invalidate the computation the next time the variable changes to or from the value. Arguments key String The name of the session variable to test value String, Number, Boolean, null, or undefined The value to test against

meteor run

meteor run Run a meteor development server in the current project. Searches upward from the current directory for the root directory of a Meteor project. Whenever you change any of the application's source files, the changes are automatically detected and applied to the running application. You can use the application by pointing your web browser at localhost:3000. No Internet connection is required. This is the default command. Simply running meteor is the same as meteor run. To pass additiona

Assets.getText

Server Assets.getText(assetPath, [asyncCallback]) Retrieve the contents of the static server asset as a UTF8-encoded string. Arguments assetPath String The path of the asset, relative to the application's private subdirectory. asyncCallback Function Optional callback, which is called asynchronously with the error or result after the function is complete. If not provided, the function runs synchronously.