code: function event(publicAPI, model, eventName, asynchrounous = true) {
    const callbacks = [];
    const previousDestroy = publicAPI.destroy;
  
    function off(index) {
      callbacks[index] = null;
    }
  
    function on(index) {
      function unsubscribe() {
        off(index);
      }
      return Object.freeze({ unsubscribe });
    }
  
    publicAPI[`fire${capitalize(eventName)}`] = (...args) => {
      if (model.deleted) {
        console.log('instance deleted - can not call any method');
        return;
      }
  
      function processCallbacks() {
        callbacks.forEach((callback) => {
          if (callback) {
            try {
              callback.apply(publicAPI, args);
            } catch (errObj) {
              console.log('Error event:', eventName, errObj);
            }
          }
        });
      }
  
      if (asynchrounous) {
        setImmediate(processCallbacks);
      } else {
        processCallbacks();
      }
    };
  
    publicAPI[`on${capitalize(eventName)}`] = (callback) => {
      if (model.deleted) {
        console.log('instance deleted - can not call any method');
        return null;
      }
  
      const index = callbacks.length;
      callbacks.push(callback);
      return on(index);
    };
  
    publicAPI.destroy = () => {
      previousDestroy();
      callbacks.forEach((el, index) => off(index));
    };
  }
docs: ---------------------------------------------------------------------------- Event handling: onXXX(callback), fireXXX(args...) ----------------------------------------------------------------------------