event-binder.js
function BindToEventDecorator(_event, _target, _listenIn, _removeIn) {
  return function(propertyName, func) {
    const scope = this;
    const event = _event || propertyName;
    const target = !_target ? this.el : document.querySelector(_target);
    if (!target) {
      console.warn("Couldn't subscribe "+this.name+"."+propertyName+" to "+event+" on "+_target
        +" because querySelector returned undefined.");
      return;
    }
    const listenIn = _listenIn || "init";
    const removeIn = _removeIn || "remove";

    const listenFunc = this[listenIn];
    const removeFunc = this[removeIn];
    const boundFunc = func.bind(this);
    
    this[listenIn] = function() {
      if (listenFunc !== undefined) {
        listenFunc.apply(scope, arguments);
      }
      target.addEventListener(event, boundFunc);
    }

    this[removeIn] = function() {
      if (removeFunc !== undefined) {
        removeFunc.apply(scope, arguments);
      }
      target.removeEventListener(event, boundFunc);
    }

    return func;
  }
}
function BindToEventDecorator(_event, _target, _listenIn, _removeIn) {
  return function(propertyName, func) {
    const scope = this;
    const event = _event || propertyName;
    const target = !_target ? this.el : document.querySelector(_target);
    if (!target) {
      console.warn("Couldn't subscribe "+this.name+"."+propertyName+" to "+event+" on "+_target
        +" because querySelector returned undefined.");
      return;
    }
    const listenIn = _listenIn || "init";
    const removeIn = _removeIn || "remove";

    const listenFunc = this[listenIn];
    const removeFunc = this[removeIn];
    const boundFunc = func.bind(this);
    
    this[listenIn] = function() {
      if (listenFunc !== undefined) {
        listenFunc.apply(scope, arguments);
      }
      target.addEventListener(event, boundFunc);
    }

    this[removeIn] = function() {
      if (removeFunc !== undefined) {
        removeFunc.apply(scope, arguments);
      }
      target.removeEventListener(event, boundFunc);
    }

    return func;
  }
}
function BindToEventDecorator ( _event , _target , _listenIn , _removeIn ) { return function ( propertyName , func ) { const scope = this ; const event = _event || propertyName ; const target = ! _target ? this . el : document . querySelector ( _target ) ; if ( ! target ) { console . warn ( "Couldn't subscribe " + this . name + "." + propertyName + " to " + event + " on " + _target + " because querySelector returned undefined." ) ; return ; } const listenIn = _listenIn || "init" ; const removeIn = _removeIn || "remove" ; const listenFunc = this [ listenIn ] ; const removeFunc = this [ removeIn ] ; const boundFunc = func . bind ( this ) ; this [ listenIn ] = function ( ) { if ( listenFunc !== undefined ) { listenFunc . apply ( scope , arguments ) ; } target . addEventListener ( event , boundFunc ) ; } this [ removeIn ] = function ( ) { if ( removeFunc !== undefined ) { removeFunc . apply ( scope , arguments ) ; } target . removeEventListener ( event , boundFunc ) ; } return func ; } }
Implements the automatic binding and unbinding of the chosen function. Wraps its listenIn and removeIn functions to add and remove the event listener at the correct times.
Implements the automatic binding and unbinding of the chosen function . Wraps its listenIn and removeIn functions to add and remove the event listener at the correct times .