Skip to content

Helpers.factoryActions()

Javi Jiménez edited this page Jun 26, 2016 · 2 revisions

A async promised function which returns the fastest action of a list:

Example

import { factoryActions } from 'ava-ia/lib/helpers';
import { forecastYahoo, forecastMSN } from 'ava-ia/lib/actions';

return factoryActions(state, actions);

Definition

'use strict';

export default async (state, actions) => {
  const promises = actions.map( (action) => action.call(null, state) );

  return await Promise.race(promises);
}

Feel free to offer new features, improvements or anything you can think of. This project makes sense with your participation and experience using Ava.

Clone this wiki locally