Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
};
//
// liftState
//
// ok
const lifted: [State, Effect] = L.liftState({ first: true, second: false });
//
// loop accessors
//
const state: State = { first: true, second: false };
const loopState: [State, Effect] = loop(
{ first: true, second: false },
Effects.constant({ type: "SECOND" })
);
// ok
const model1: State = L.getModel(loopState);
// ok
const model2: State = L.getModel(state);
// ok
const effect1: Effect = L.getEffect(loopState);
// ok
const effect2: null = L.getEffect(state);
function callReducer (methodActions, startReducer, state, action) {
const payload = action.payload
const service = payload.service
const method = payload.method
const args = payload.args
const cid = createCid()
const startPayload = callArgs[method].apply(null, args)
const startAction = methodActions.start(cid, startPayload)
console.log('state', state)
console.log('action', action)
console.log('next state', startReducer(state, startAction))
return Loop.loop(
startReducer(state, startAction),
Loop.Effects.promise(callEffect, methodActions, cid, payload)
)
}
splitRequest: (state, { payload: orientation }) => {
const effect = orientation !== state.orientation
? Effects.constant(module.actions.split(orientation))
: Effects.constant(module.actions.addChild());
return loop(state, effect);
},
updateChild: ({ children, ...state }, { payload, meta }) => {
function toReduxLoop(reduction) {
const [newState, effects] = reduction;
return loop(newState, toReduxLoopEffect(effects));
}
function toReduxLoop(reduction) {
const [newState, effects] = reduction;
return loop(newState, toReduxLoopEffect(effects));
}
updateChild: ({ children, ...state }, { payload, meta }) => {
const childToUpdate = children[meta.id];
const [updatedChild, neff] = module.reducer(childToUpdate, payload);
const effects =
Effects.lift(neff, a => module.actions.updateChild(a, { id: meta.id }));
return loop(
{ ...state, children: { ...children, [meta.id]: updatedChild } },
effects,
);
},
},