How to use emitter - 10 common examples

To help you get started, we’ve selected a few emitter 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 component / popup / index.js View on Github external
}

  // turn the "opts" object into a window.open()-compatible String
  var optsStr = [];
  for (var key in opts) {
    optsStr.push(key + '=' + opts[key]);
  }
  optsStr = optsStr.join(',');

  // every popup window has a unique "name"
  var name = opts.name;

  // if a "name" was not provided, then create a random one
  if (!name) name = 'popup-' + (Math.random() * 0x10000000 | 0).toString(36);

  Emitter.call(this);
  this.name = name;
  this.opts = opts;
  this.optsStr = optsStr;

  // finally, open and return the popup window
  this.window = window.open(src, name, optsStr);
  this.focus();

  this.interval = setInterval(checkClose(this), interval);
}
github matthewmueller / autocomplete / index.js View on Github external
this.coords = getOffset(el);
  this.url = url;
  this._when = false;
  this._display = true;
  this.throttle = opts.throttle || 200;
  this.headers = opts.headers || {};
  this.throttledSearch = throttle(this.search.bind(this), this.throttle);
  this._key = el.getAttribute('name');
  this.formatter = function(item) { return item; };

  // Prevents the native autocomplete from showing up
  this.el.setAttribute('autocomplete', 'off');

  classes(this.el).add('autocomplete');

  Emitter.call(this);

  this.enable();
}
github DemocracyOS / bill-tracker / lib / view / view.js View on Github external
function View(template, locals) {
  if (!(this instanceof View))
    return inherit(template, View);
  
  Emitter.call(this);
  this.template = template;
  this.locals = locals || {};
  this.build();
}
github component / calendar / lib / calendar.js View on Github external
function Calendar(date) {
  if (!(this instanceof Calendar)) {
    return new Calendar(date);
  }

  Emitter.call(this);
  var self = this;
  this.el = domify('<div class="calendar"></div>');
  this.days = new Days;
  this.el.appendChild(this.days.el);
  this.on('change', bind(this, this.show));
  this.days.on('prev', bind(this, this.prev));
  this.days.on('next', bind(this, this.next));
  this.days.on('year', bind(this, this.menuChange, 'year'));
  this.days.on('month', bind(this, this.menuChange, 'month'));
  this.show(date || new Date);
  this.days.on('change', function(date){
    self.emit('change', date);
  });
}
github component / notification / index.js View on Github external
function Notification(options) {
  Emitter.call(this);
  options = options || {};
  this.el = dom(require('./template'));
  this.render(options);
  if (options.classname) this.el.addClass(options.classname);
  if (Notification.effect) this.effect(Notification.effect);
}
github repetere / periodicjs / content / extensions / node_modules / periodicjs.ext.install / node_modules / superagent / lib / client.js View on Github external
function Request(method, url) {
  var self = this;
  Emitter.call(this);
  this._query = this._query || [];
  this.method = method;
  this.url = url;
  this.header = {};
  this._header = {};
  this.on('end', function(){
    var res = new Response(self);
    if ('HEAD' == method) res.text = null;
    self.callback(null, res);
  });
}
github bertyhell / CodeClassifier / CodeClassifier / training-set / javascript / javascript.js View on Github external
function Request(method, url) {
  var self = this;
  Emitter.call(this);
  this._query = this._query || [];
  this.method = method;
  this.url = url;
  this.header = {};
  this.set('X-Requested-With', 'XMLHttpRequest');
  this.on('end', function(){
    self.callback(null, new Response(self.xhr));
  });
}
github fomantic / Fomantic-UI / node / node_modules / docpad / node_modules / superagent / lib / client.js View on Github external
function Request(method, url) {
  var self = this;
  Emitter.call(this);
  this._query = this._query || [];
  this.method = method;
  this.url = url;
  this.header = {};
  this._header = {};
  this.on('end', function(){
    var res = new Response(self);
    if ('HEAD' == method) res.text = null;
    self.callback(null, res);
  });
}
github nfriedly / nfriedly.com / node_modules / docpad / node_modules / superagent / lib / client.js View on Github external
function Request(method, url) {
  var self = this;
  Emitter.call(this);
  this._query = this._query || [];
  this.method = method;
  this.url = url;
  this.header = {};
  this._header = {};
  this.on('end', function(){
    var res = new Response(self);
    if ('HEAD' == method) res.text = null;
    self.callback(null, res);
  });
}
github taskcluster / taskcluster / services / auth / node_modules / superagent / lib / client.js View on Github external
function Request(method, url) {
  var self = this;
  Emitter.call(this);
  this._query = this._query || [];
  this.method = method;
  this.url = url;
  this.header = {};
  this._header = {};
  this.on('end', function(){
    var res = new Response(self);
    if ('HEAD' == method) res.text = null;
    self.callback(null, res);
  });
}

emitter

Faster events controller for class and object

MIT
Latest version published 9 years ago

Package Health Score

40 / 100
Full package analysis

Popular emitter functions