node package manager


An observable module for objects and arrays


An observable module for objects and arrays

Install the module with: npm install telescope --save

makeArrayObservable = require("telescope").array;
var tabs = [],
    observableTabs = makeArrayObservable();

observableTabs is an array that emits events on push or remove of items.

When you push or remove items to observableTabs, they are pushed or removed from tabs array, plus a "changed" event is emitted.

Pushing method create also an object observable on pushed item, that is returned from the function.

    var Observable = require("telescope").object;
    function ConcreteObservable(observed){
    ConcreteObservable.prototype = new Observable();
    var anObject = {
    var observable = new ConcreteObservable(anObject);

observable is now an object that wrap anObject and create a property for each of its property.

These property set and get values of corresponding anObject property, emitting "changed" events when property values are set.

The init pattern allow to setup derived property that are set on main property change, e.g. sum, totals, etc.

See test folder for more usage exmaples

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality.

Copyright (c) 2013 parroit
Licensed under the MIT license.