How to use delegates - 3 common examples

To help you get started, we’ve selected a few delegates examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github trekjs / route-mapper / src / route.js View on Github external
if (/^\//.test(controller)) {
        return controller.substr(1);
      } else {
        if (/^\//.test(modyoule)) {
          modyoule = modyoule.substr(1);
        }
        return _.compact([modyoule, controller]).join('/');
      }
    }
    return controller;
  }

}

// Delegates
delegate(Route.prototype, 'options')
  .getter('format')
  .getter('as')
  .getter('to')

export default Route;
github trekjs / route-mapper / src / route_mapper.js View on Github external
'get',
  'options',
  'post',
  'put',
  'patch',
  // delete
  'delete',
  'del'
].forEach((verb) => {
  RouteMapper.prototype[verb] = function() {
    return this._mapMethod(verb, arguments);
  };
});

// Delegates
delegate(RouteMapper.prototype, '$scope')
  .getter('isResources')
  .getter('isResourceScope')
  .getter('isNestedScope')
  .getter('isResourceMethodScope')

export default RouteMapper;
github matthewmueller / spreadsheet / dist / spreadsheet.js View on Github external
var e = parse(event);
  var el = this.el;
  var obj = this.obj;
  var name = e.name;
  var method = method || 'on' + name;
  var args = [].slice.call(arguments, 2);

  // callback
  function cb(){
    var a = [].slice.call(arguments).concat(args);
    obj[method].apply(obj, a);
  }

  // bind
  if (e.selector) {
    cb = delegate.bind(el, e.selector, name, cb);
  } else {
    events.bind(el, name, cb);
  }

  // subscription for unbinding
  this.sub(name, method, cb);

  return cb;
};

delegates

delegate methods and accessors to another property

MIT
Latest version published 9 years ago

Package Health Score

71 / 100
Full package analysis

Popular delegates functions