How to use the redux-loop.Effects.promise 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_effects.js View on Github external
Effects.call(string, "one", "two");

//
// Effects.promise
//

function asyncActionCreator(x: string, y: number) {
  return Promise.resolve({
    type: "asyncAction",
    x,
    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
github minedeljkovic / redux-elmish / src / install.js View on Github external
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)));
    }
  }
}
github mboperator / infinitely-composable-webapp-demo / src / components / PokemonMe / module.js View on Github external
reducer: (state, { payload: pokemonNumber }) => loop(
        { ...state, loading: true },
        Ef.promise(
          pokemonApi.fetch({
            onSuccess: module.actions.fetchSuccess,
            onError: module.actions.fetchError,
            pokemonNumber,
          }),
        ),
      ),
    },
github minedeljkovic / redux-elmish / examples / pair-of-counters / src / boilerplate.js View on Github external
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) {
github raisemarketplace / ground-control / examples / full / routes / child-routes / loop-loop-loop / components / index.js View on Github external
[actions.loop]: state => {
    const nextState = { ...state, text: `${state.text}${LOOOOP}` };
    const effect = nextState.text.length <= LOOOOP.length * 2 ? Effects.promise(delayedLoop) : Effects.none();
    return loop(nextState, effect);
  },
}, { text: LOOOOP });