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

        if (!this._bindingListenerRemovers) {
          this._bindingListenerRemovers = [];
        }

        var effectiveBinding = args.binding || this.getDefaultBinding();
        if (!effectiveBinding) {
          return console.warn('Morearty: cannot attach binding listener to a component without default binding');
        }
        var listenerId = effectiveBinding.addListener(args.subpath, args.cb);
        this._bindingListenerRemovers.push(function () {
          effectiveBinding.removeListener(listenerId);
        });

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

        if (!this._bindingListenerRemovers) {
          this._bindingListenerRemovers = [];
        }

        var effectiveBinding = args.binding || this.getDefaultBinding();
        if (!effectiveBinding) {
          return console.warn('Morearty: cannot attach binding listener to a component without default binding');
        }
        var listenerId = effectiveBinding.addListener(args.subpath, args.cb);
        this._bindingListenerRemovers.push(function () {
          effectiveBinding.removeListener(listenerId);
        });

        return listenerId;
      }
function ( binding , subpath , cb ) { var args = Util . resolveArgs ( arguments , function ( x ) { return x instanceof Binding ? 'binding' : null ; } , function ( x ) { return Util . canRepresentSubpath ( x ) ? 'subpath' : null ; } , 'cb' ) ; if ( ! this . _bindingListenerRemovers ) { this . _bindingListenerRemovers = [ ] ; } var effectiveBinding = args . binding || this . getDefaultBinding ( ) ; if ( ! effectiveBinding ) { return console . warn ( 'Morearty: cannot attach binding listener to a component without default binding' ) ; } var listenerId = effectiveBinding . addListener ( args . subpath , args . cb ) ; this . _bindingListenerRemovers . push ( function ( ) { effectiveBinding . removeListener ( listenerId ) ; } ) ; return listenerId ; }
Add binding listener. Listener will be automatically removed on unmount.
@param {Binding} [binding] binding to attach listener to, default binding if omitted
@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} listener id
Add binding listener . Listener will be automatically removed on unmount .