How to use the redux-loop.loop function in redux-loop

To help you get started, we’ve selected a few redux-loop examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github flow-typed / flow-typed / definitions / npm / redux-loop_v2.2.x / flow_v0.33.x- / test_loop.js View on Github external
};

//
// 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);
github root-systems / feathers-action / src / reducer.js View on Github external
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)
  )
}
github mboperator / infinitely-composable-webapp-demo / src / components / Dashboard / module.js View on Github external
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 }) => {
github minedeljkovic / redux-elmish / src / install.js View on Github external
function toReduxLoop(reduction) {
  const [newState, effects] = reduction;
  return loop(newState, toReduxLoopEffect(effects));
}
github minedeljkovic / redux-elmish / examples / pair-of-counters / src / boilerplate.js View on Github external
function toReduxLoop(reduction) {
  const [newState, effects] = reduction;
  return loop(newState, toReduxLoopEffect(effects));
}
github mboperator / infinitely-composable-webapp-demo / src / components / Dashboard / module.js View on Github external
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,
      );
    },
  },