import { pipeActions } from './actionHandler/utils';

export function emitCustomEvent(instance, trigger, global, meta) {
  const actions = instance.actions.filter(i => i.trigger === trigger);
  if (!actions.length) {
    return;
  }

  const handler = pipeActions(actions);
  return handler({ global, meta });
}
