// create a dispatch event function that also calls to the onevent function in case  it's set
// usage example:
// #dispatchSomething = createDispatchEvent.bind(this, 'something' { ...options })
// this will dispatch a new event when called, but also call to "onsomething"
export function createDispatchEvent(eventName, options = {}) {
  const event = new Event(eventName, options);

  this[`on${eventName}`]?.(event); // in case we got an event callback as property
  this.dispatchEvent(event);
}
