Store
The Duck Store.
Recipe
function Store(data) {
  const events = {};

  // ...

  return {
    // ...
    on, off
  };

  ////////////////////////////////
  // events
  function on(name, handler) {
    if(!events[name]) { events[name] = []; }
    events[name].push(handler);
  }
  function off(name, handler) {
    if(events[name]) {
      const index = events[name].indexOf(handler);
      if(index != -1) { events[name].splice(index, 1); }
    }
  }
  function emit(name, value) {
    if(events[name]) {
      for(let i = 0; i < events[name].length; i++) {
        events[name][i](value);
      }
    }
  }
  ////////////////////////////////
}
JavaScript
Walkthrough
See core.