index.js
/**
   * Adds an observer to a collection and returns the observer.
   * Observation can be stopped by calling the stop() method on the observer.
   * Functions for added, updated and removed can be added to the observer
   * afterward.
   */
Adds an observer to a collection and returns the observer.
Observation can be stopped by calling the stop() method on the observer.
Functions for added, updated and removed can be added to the observer
afterward.
Adds an observer to a collection and returns the observer . Observation can be stopped by calling the stop () method on the observer . Functions for added updated and removed can be added to the observer afterward .
observe(name, added, updated, removed) {
    var self = this;
    var observer = {};
    var id = self._getNextId();
    Object.defineProperty(observer, "name", {
      get: function() { return name; },
      enumerable: true
    });
    Object.defineProperty(observer, "_id", { get: function() { return id; }});
    observer.added   = added   || function(){};
    observer.updated = updated || function(){};
    observer.removed = removed || function(){};
    observer.stop = function() {
      self._removeObserver(observer);
    };
    self._addObserver(observer);
    return observer;
  }
observe ( name , added , updated , removed ) { var self = this ; var observer = { } ; var id = self . _getNextId ( ) ; Object . defineProperty ( observer , "name" , { get : function ( ) { return name ; } , enumerable : true } ) ; Object . defineProperty ( observer , "_id" , { get : function ( ) { return id ; } } ) ; observer . added = added || function ( ) { } ; observer . updated = updated || function ( ) { } ; observer . removed = removed || function ( ) { } ; observer . stop = function ( ) { self . _removeObserver ( observer ) ; } ; self . _addObserver ( observer ) ; return observer ; }
Adds an observer to a collection and returns the observer.
Adds an observer to a collection and returns the observer .
// name, _id are immutable