How to use the evt.prototype function in evt

To help you get started, we’ve selected a few evt 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 ftlabs / fruitmachine / lib / module / events.js View on Github external
// if a module is provided
  // pass in a special callback
  // function that checks the
  // module
  if (module) {
    if (!listenerMap[name]) listenerMap[name] = [];
    l = listenerMap[name].push({
      orig: cb,
      cb: function() {
        if (this.event.target.module() === module) {
          cb.apply(this, arguments);
        }
      }
    });
    events.prototype.on.call(this, name, listenerMap[name][l-1].cb);
  } else {
    events.prototype.on.call(this, name, cb);
  }

  return this;
};
github ftlabs / fruitmachine / lib / module / events.js View on Github external
// If a callback provided, keep it
      // in the listener map if it doesn't match
      if (cb && map.orig !== cb) {
        return true;

      // Otherwise remove it from the listener
      // map and unbind the event listener
      } else {
        events.prototype.off.call(this, name, map.cb);
        return false;
      }
    }, this);
  }
  if (!module) {
    events.prototype.off.call(this, name, cb);
  }

  return this;
};
github ftlabs / fruitmachine / lib / module / events.js View on Github external
function propagate(view, args, event) {
  if (!view || !event.propagate) return;

  view.event = event;
  events.prototype.fire.apply(view, args);
  propagate(view.parent, args, event);
}