UNPKG

patronum

Version:

☄️ Effector utility library delivering modularity and convenience

34 lines (33 loc) 778 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.inFlight = inFlight; var _effector = require("effector"); function inFlight(args) { const argsShape = Array.isArray(args) ? { effects: args } : args; const { effects, domain } = argsShape; if (domain) { const $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 (0, _effector.combine)({ and: [effects.map(fx => fx.inFlight), inFlights => inFlights.reduce((all, current) => all + current, 0), { skipVoid: false }], or: { sid: "udy3nn" } }); }