Skip to content
A fork of Meteor Tracker, repackaged as a standalone library.
JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
test
.gitignore
.npmignore
LICENSE
README.md
package.json
trackr.js

README.md

Trackr

This is a fork of Meteor Tracker, the library formerly known as Meteor Deps. It has been repackaged into a standalone library that is ready to use in Node.js and the browser.

Trackr's API is completely backwards compatible with Meteor's version. If you are not familiar with Meteor Tracker, or reactive programming in general, I recommend reading the Meteor Manual entry on Deps. The concepts it teaches apply here as well.

Install

Download the latest version from the release page and use via a script tag. The variable Trackr will be attached to window.

<script type="text/javascript" src="trackr.js"></script>

For Browserify and Node.js, install via NPM and require as necessary.

$ npm install trackr
var Trackr = require("trackr");

Usage

The only change that has been made is the addition of function context. Method context (this) can be added as an optional argument to the end of methods that accept functions. For example, here is how you would use autorun() with context:

var ctx = { foo: "bar" };

var comp = Trackr.autorun(function() {
    console.log(this.foo); // "bar"
}, { /* options */ }, ctx);

This also works for onInvalidate() and afterFlush() callbacks. onInvalidate() will fallback on the context provided to the computation if none is provided.

comp.onInvalidate(function() {
    console.log(this.foo); // "bar"
});

Trackr.afterFlush(function() {
    console.log(this.hello); // "world"
}, {
    hello: "world"
});
You can’t perform that action at this time.