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);
// $ExpectError
const effect3: Effect = L.getEffect(state);
//
// Effects.none
//
// ok
const none: Effect = Effects.none();
//
// Effects.constant
//
// ok
const constant: Effect = Effects.constant({ type: "foo" });
// $ExpectError
Effects.constant({ noTypeProp: "foo" });
//
// Effects.call
//
function zeroArg() {
return { type: "zeroArg" };
}
function string(x: string) {
return { type: "string", x };
}
function numberString(x: number, y: string) {
return { type: "numberString", x, y };
}
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 }) => {
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 }) => {