UNPKG

patronum

Version:

☄️ Effector utility library delivering modularity and convenience

39 lines (38 loc) 1.05 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.pending = pending; var _effector = require("effector"); const strategies = { some: list => list.some(Boolean), every: list => list.every(Boolean) }; function pending(args) { const argsShape = Array.isArray(args) ? { effects: args } : args; const { effects: rawEffects, domain, of = 'some' } = argsShape; if (!_effector.is.domain(domain, { sid: "98ymuf" }) && !rawEffects) throw new TypeError('domain or effects should be passed'); if (of !== 'some' && of !== 'every') throw new TypeError(`strategy parameter "of" can be "every" or "some". Passed: "${of}"`); let effects = rawEffects !== null && rawEffects !== void 0 ? rawEffects : []; const strategy = strategies[of]; if (domain) { effects = []; domain.onCreateEffect(fx => effects.push(fx)); } return (0, _effector.combine)({ and: [effects.map(fx => fx.pending), strategy, { skipVoid: false }], or: { sid: "a4upb3" } }); }