patronum
Version:
☄️ Effector utility library delivering modularity and convenience
33 lines • 936 B
JavaScript
import { combine, is } from 'effector';
var strategies = {
some: list => list.some(Boolean),
every: list => list.every(Boolean)
};
export function pending(args) {
var argsShape = Array.isArray(args) ? {
effects: args
} : args;
var {
effects: rawEffects,
domain,
of = 'some'
} = argsShape;
if (!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: \"".concat(of, "\""));
var effects = rawEffects !== null && rawEffects !== void 0 ? rawEffects : [];
var strategy = strategies[of];
if (domain) {
effects = [];
domain.onCreateEffect(fx => effects.push(fx));
}
return combine({
and: [effects.map(fx => fx.pending), strategy, {
skipVoid: false
}],
or: {
sid: "a4upb3"
}
});
}