src/Binding.js
function (subpath, cb) {
    var args = Util.resolveArgs(
      arguments, function (x) { return Util.canRepresentSubpath(x) ? 'subpath' : null; }, 'cb'
    );

    var listenerId = generateListenerId();
    var pathAsString = asStringPath(Util.joinPaths(this._path, asArrayPath(args.subpath || '')));
    var samePathListeners = this._sharedInternals.listeners[pathAsString];
    var listenerDescriptor = { cb: args.cb, disabled: false };
    if (samePathListeners) {
      samePathListeners[listenerId] = listenerDescriptor;
    } else {
      var listeners = {};
      listeners[listenerId] = listenerDescriptor;
      this._sharedInternals.listeners[pathAsString] = listeners;
    }
    return listenerId;
  }
function (subpath, cb) {
    var args = Util.resolveArgs(
      arguments, function (x) { return Util.canRepresentSubpath(x) ? 'subpath' : null; }, 'cb'
    );

    var listenerId = generateListenerId();
    var pathAsString = asStringPath(Util.joinPaths(this._path, asArrayPath(args.subpath || '')));
    var samePathListeners = this._sharedInternals.listeners[pathAsString];
    var listenerDescriptor = { cb: args.cb, disabled: false };
    if (samePathListeners) {
      samePathListeners[listenerId] = listenerDescriptor;
    } else {
      var listeners = {};
      listeners[listenerId] = listenerDescriptor;
      this._sharedInternals.listeners[pathAsString] = listeners;
    }
    return listenerId;
  }
function ( subpath , cb ) { var args = Util . resolveArgs ( arguments , function ( x ) { return Util . canRepresentSubpath ( x ) ? 'subpath' : null ; } , 'cb' ) ; var listenerId = generateListenerId ( ) ; var pathAsString = asStringPath ( Util . joinPaths ( this . _path , asArrayPath ( args . subpath || '' ) ) ) ; var samePathListeners = this . _sharedInternals . listeners [ pathAsString ] ; var listenerDescriptor = { cb : args . cb , disabled : false } ; if ( samePathListeners ) { samePathListeners [ listenerId ] = listenerDescriptor ; } else { var listeners = { } ; listeners [ listenerId ] = listenerDescriptor ; this . _sharedInternals . listeners [ pathAsString ] = listeners ; } return listenerId ; }
Add change listener.
@param {String|Array} [subpath] subpath as a dot-separated string or an array of strings and numbers
@param {Function} cb function receiving changes descriptor
@return {String} unique id which should be used to un-register the listener
@see ChangesDescriptor
Add change listener .