UNPKG

patronum

Version:

☄️ Effector utility library delivering modularity and convenience

28 lines 654 B
import { combine } from 'effector'; export function inFlight(args) { var argsShape = Array.isArray(args) ? { effects: args } : args; var { effects, domain } = argsShape; if (domain) { var $inFlight = domain.createStore(0, { name: "$inFlight", sid: "-wboyn1" }); domain.onCreateEffect(fx => { $inFlight.on(fx, count => count + 1).on(fx.finally, count => count - 1); }); return $inFlight; } return combine({ and: [effects.map(fx => fx.inFlight), inFlights => inFlights.reduce((all, current) => all + current, 0), { skipVoid: false }], or: { sid: "udy3nn" } }); }