UNPKG

@nent/core

Version:

Functional elements to add routing, data-binding, dynamic HTML, declarative actions, audio, video, and so much more. Supercharge static HTML files into web apps without script or builds.

31 lines (30 loc) 994 B
/*! * NENT 2022 */ import { ActionActivationStrategy, } from './interfaces'; /** * Activates action activators * @param actionActivators * @param forEvent * @param [filter] */ export async function activateActionActivators(actionActivators, forEvent, filter = _a => true) { let once = forEvent == ActionActivationStrategy.AtTime || forEvent == ActionActivationStrategy.AtTimeEnd; await Promise.all(actionActivators .filter(activator => activator.activate === forEvent) .filter(filter) .map(async (activator) => { await activator.activateActions(once); })); } /** * It sends all the actions in the array that pass the filter function * @param {IActionElement[]} actions - An array of IActionElement objects. * @param filter - (action: IActionElement | any) => boolean = _a => true, */ export async function sendActions(actions, filter = _a => true) { await Promise.all(actions.filter(filter).map(async (action) => { await action.sendAction(); })); }