node package manager



Greenkeeper badge

Build Status

Core observable indicators.



new Observation(func, context, compute)

observed {Object}

An object representing an observation.

{ "obj": map, "event": "prop1" }
  • obj {Object}: The observable object
  • event {String}: The event, or more likely property, that is being observed.

Observation.add(obj, event)

Signals that an event should be observed. Adds the observable being read to the top of the stack.

Observation.add(obj, "prop1");
  1. obj {Object}: An observable object which is being observed.
  2. event {String}: The name of the event (or property) that is being observed.


The same as Observation.add but takes an array of observed objects. This will most often by used in coordination with trap:

var untrap = Observation.trap();
Observation.add(obj, "prop3");
var traps = untrap();
  1. observes {Array<observed>}: An array of observeds.


Creates a function that, when called, will prevent observations from being applied.

var fn = Observation.ignore(function(){
  // This will be ignored 
  Observation.add(obj, "prop1");
Observation.trapCount(); // -> 0 
  1. fn {function}: Any function that contains potential calls to add.
  • returns {function}: A function that is free of observation side-effects.


Trap all observations until the untrap function is called. The state of traps prior to Observation.trap() will be restored when untrap() is called.

var untrap = Observation.trap();
Observation.add(obj, "prop1");
var traps = untrap();
console.log(traps[0].obj === obj); // -> true 
  • returns {function}: A function to untrap the current observations.


Returns if some function is in the process of recording observes.

  • returns {Boolean}: True if a function is in the process of recording observes.


Making a Build

To make a build of the distributables into dist/ in the cloned repository run

npm install
node build

Running the tests

Tests can run in the browser by opening a webserver and visiting the test.html page. Automated tests that run the tests from the command line in Firefox can be run with

npm test