Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
y
});
}
// ok
Effects.promise(asyncActionCreator, "one", 2);
// $ExpectError
Effects.promise(asyncActionCreator, 1, "two");
//
// Effects.batch
//
// ok
Effects.batch([
Effects.call(zeroArg),
Effects.promise(asyncActionCreator, "one", 2)
]);
//
// Effects.lift
//
function nestedAction(time: Date, action: { type: $Subtype }) {
return { type: "NESTED_ACTION", payload: action, time };
}
function nestedActionWrongArgOrder(
action: { type: $Subtype },
time: Date
) {
function toReduxLoopEffect(effect) { // eslint-disable-line consistent-return
switch (effect.type) { // eslint-disable-line default-case
case 'NONE': return Effects.none();
case 'PROMISE': {
const factory = () => { // eslint-disable-line arrow-body-style
return effect.factory()
.then(result => effect.successTagger(result), error => effect.failTagger(error));
};
return Effects.promise(factory);
}
case 'MAP': {
return Effects.lift(toReduxLoopEffect(effect.effect), effect.tagger);
}
case 'BATCH': {
return Effects.batch(effect.effects.map(batchedEffect => toReduxLoopEffect(batchedEffect)));
}
}
}
function toReduxLoopEffect(effect) {
switch(effect.type) {
case 'NONE': return Effects.none();
case 'PROMISE': {
const factory = () => {
return effect.factory()
.then(result => effect.successTagger(result), error => effect.failTagger(error))
};
return Effects.promise(factory);
};
case 'MAP': {
return Effects.lift(toReduxLoopEffect(effect.effect), effect.tagger);
};
case 'BATCH': {
return Effects.batch(effect.effects.map(batchedEffect => toReduxLoopEffect(batchedEffect)));
};
}
}
function toReduxLoop(reduction) {
split: (state, { payload: orientation }) => {
const reduceChild = [module.reducer, module.actions.init];
const childrenModels = [[state], [undefined]];
const [children, childrenEff] = composeLoops(reduceChild, childrenModels);
const effects = Effects.batch(
childrenEff.map((effect, id) =>
Effects.lift(effect, a => module.actions.updateChild(a, { id })),
),
);
return loop(
{ ...state, orientation, children: children.reduce((acc, child) => ({ ...acc, [v4()]: child }), {}) },
effects,
);
},
splitRequest: (state, { payload: orientation }) => {