rootComponents/on/on.js

// local dependencies
import store from '../../store/store';
import C from '../../constants/constants';

/**
 * Attaches the callback's associated with the WebGL canvas element to the event.
 *
 * @module on
 * @memberOf module:rootComponents
 * @param {object} event - The event for the callback.
 * @param {function} [callback] - The specific callback to attach to the `event`.
 * @returns {self} - Chainable api by returning the instance.
 *
 * @example
 * function clickCallback() {
 *   console.log('CLICKED');
 * }
 *
 * $$$
 * .on('click', clickCallback)
 * .trigger('click') // logs 'CLICKED'
 */
export default function(event, callback) {
  store
  .get(C.$CANVAS)
  .on(event, callback);
  return this;
};