Skip to content

A fork of Meteor Tracker, repackaged as a standalone library.

License

Notifications You must be signed in to change notification settings

BeneathTheInk/trackr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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"
});

About

A fork of Meteor Tracker, repackaged as a standalone library.

Resources

License

Stars

Watchers

Forks

Packages

No packages published