How to use redux-saga - 10 common examples

To help you get started, we’ve selected a few redux-saga 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-saga_v1.x.x / flow_v0.76.0- / test_redux-saga_1.x.x_putResolve.js View on Github external
it("must raises an error when pass EventChannel", () => {
      const myEventChannel = eventChannel(emitter => () => {});
      const myAction = { type: "test" };

      // $ExpectError: event channel hasn"t a put() property
      putResolve(myEventChannel, myAction);
    });
github flow-typed / flow-typed / definitions / npm / redux-saga_v0.16.x / flow_v0.56.0- / test_redux-saga_0.16.x.js View on Github external
function contextSpawnTest() {
  const e0 = spawn([context, fn0]);
  const e1 = spawn([context, fn1], "1");
  const e2 = spawn([context, fn2], "1", 2);
  const e3 = spawn([context, fn3], "1", 2, "3");
  const e4 = spawn([context, fn4], "1", 2, "3", 4);
  const e5 = spawn([context, fn5], "1", 2, "3", 4, "5");
  const e6 = spawn([context, fn6], "1", 2, "3", 4, "5", 6);
  const e7 = spawn([context, fn7], "1", 2, "3", 4, "5", 6, "7");
  const e8 = spawn([context, fn8], "1", 2, "3", 4, "5", 6, "7", 8);
  const eClass = spawn([context, fn1], "1");
  const eSaga = spawn([context, s1], "1");

  // Args Test
  (e0.SPAWN.args: []);
  (e1.SPAWN.args: [string]);
  (e2.SPAWN.args: [string, number]);
  (e3.SPAWN.args: [string, number, string]);
  (e4.SPAWN.args: [string, number, string, number]);
  (e5.SPAWN.args: [string, number, string, number, string]);
  (e6.SPAWN.args: [string, number, string, number, string, number]);
  (e7.SPAWN.args: [string, number, string, number, string, number, string]);
  (e8.SPAWN.args: [string, number, string, number, string, number, string, number]);

  // Context Test
  (e1.SPAWN.context: typeof context);
  (e2.SPAWN.context: typeof context);
github redux-saga / redux-saga / packages / core / __tests__ / typescript / effects.ts View on Github external
function* testCancel(): SagaIterator {
  yield cancel()

  // typings:expect-error
  yield cancel(undefined)
  // typings:expect-error
  yield cancel({})

  yield cancel(task)
  // typings:expect-error
  yield cancel(task, task)
  yield cancel([task, task])
  yield cancel([task, task, task])

  const tasks: Task[] = []

  yield cancel(tasks)
github redux-saga / redux-saga / packages / core / __tests__ / typescript / effects.ts View on Github external
// typings:expect-error
  yield apply(obj, obj.meth1)
  // typings:expect-error
  yield apply(obj, obj.meth1, [])
  // typings:expect-error
  yield apply(obj, obj.meth1, [1])
  yield apply(obj, obj.meth1, ['a'])
  yield apply number>(obj, obj.meth1, ['a'])

  // typings:expect-error
  yield apply(obj, 'meth1')
  // typings:expect-error
  yield apply(obj, 'meth1', [])
  // typings:expect-error
  yield apply(obj, 'meth1', [1])
  yield apply(obj, 'meth1', ['a'])
  yield apply(obj, 'meth1', ['a'])

  // typings:expect-error
  yield apply(obj, obj.meth2, ['a'])
  // typings:expect-error
  yield apply(obj, obj.meth2, ['a', 'b'])
  // typings:expect-error
  yield apply(obj, obj.meth2, [1, 'b'])
  yield apply(obj, obj.meth2, ['a', 1])
  yield apply number>(obj, obj.meth2, ['a', 1])

  // typings:expect-error
  yield apply(obj, 'meth2', ['a'])
  // typings:expect-error
  yield apply(obj, 'meth2', ['a', 'b'])
  // typings:expect-error
github flow-typed / flow-typed / definitions / npm / redux-saga_v0.13.x / flow_v0.28.x-v0.37.x / test_redux-saga_0.13.x.js View on Github external
function applyTest() {
  const c0 = apply(context, fn0);
  const c1 = apply(context, fn1, '1');
  const c2 = apply(context, fn2, '1', 2);
  const c3 = apply(context, fn3, '1', 2, '3');
  const c4 = apply(context, fn4, '1', 2, '3', 4);
  const c5 = apply(context, fn5, '1', 2, '3', 4, '5');
  const c6 = apply(context, fn6, '1', 2, '3', 4, '5', 6);
  const cClass = apply(context2, fn1, '1');

  // Fn tests
  (c1.CALL.fn: typeof fn1);
  (c2.CALL.fn: typeof fn2);
  (c3.CALL.fn: typeof fn3);
  (c4.CALL.fn: typeof fn4);
  (c5.CALL.fn: typeof fn5);
  (c6.CALL.fn: typeof fn6);

  // $ExpectError: Wrong number of parameters
  (c6.CALL.fn: typeof fn1);
github redux-saga / redux-saga / packages / core / __tests__ / typescript / effects.ts View on Github external
getFoo() {
      return this.foo
    },
    meth1(a: string) {
      return 1
    },
    meth2(a: string, b: number) {
      return 1
    },
    meth7(a: string, b: number, c: string, d: number, e: string, f: number, g: string) {
      return 1
    },
  }

  // typings:expect-error
  yield apply(obj, obj.foo, [])
  yield apply(obj, obj.getFoo, [])
  yield apply string>(obj, obj.getFoo, [])

  // typings:expect-error
  yield apply(obj, 'foo', [])
  yield apply(obj, 'getFoo', [])
  yield apply(obj, 'getFoo', [])

  // typings:expect-error
  yield apply(obj, obj.meth1)
  // typings:expect-error
  yield apply(obj, obj.meth1, [])
  // typings:expect-error
  yield apply(obj, obj.meth1, [1])
  yield apply(obj, obj.meth1, ['a'])
  yield apply number>(obj, obj.meth1, ['a'])
github flow-typed / flow-typed / definitions / npm / redux-saga_v0.11.x / flow_v0.38.x-v0.67.x / test_redux-saga_0.11.x.js View on Github external
function cpsTest() {
  const e0 = cps(fn0);
  const e1 = cps(fn1, '1');
  const e2 = cps(fn2, '1', 2);
  const e3 = cps(fn3, '1', 2, '3');
  const e4 = cps(fn4, '1', 2, '3', 4);
  const e5 = cps(fn5, '1', 2, '3', 4, '5');
  const e6 = cps(fn6, '1', 2, '3', 4, '5', 6);
  const eClass = cps(fn1, '1');
  const eGen = cps(g1, '1');

  // Args Test
  (e0.CPS.args: []);
  (e1.CPS.args: [string]);
  (e2.CPS.args: [string, number]);
  (e3.CPS.args: [string, number, string]);
  (e4.CPS.args: [string, number, string, number]);
  (e5.CPS.args: [string, number, string, number, string]);
  (e6.CPS.args: [string, number, string, number, string, number]);

  // Fn Test
  (e1.CPS.fn: typeof fn1);
github flow-typed / flow-typed / definitions / npm / redux-saga_v0.16.x / flow_v0.56.0- / test_redux-saga_0.16.x.js View on Github external
function cpsTest() {
  const e0 = cps(cpsfn0);
  const e1 = cps(cpsfn1, "1");
  const e2 = cps(cpsfn2, "1", 2);
  const e3 = cps(cpsfn3, "1", 2, "3");
  const e4 = cps(cpsfn4, "1", 2, "3", 4);
  const e5 = cps(cpsfn5, "1", 2, "3", 4, "5");
  const e6 = cps(cpsfn6, "1", 2, "3", 4, "5", 6);
  const e7 = cps(cpsfn7, "1", 2, "3", 4, "5", 6, "7");
  const e8 = cps(cpsfn8, "1", 2, "3", 4, "5", 6, "7", 8);

  // Args Test
  (e0.CPS.args: []);
  (e1.CPS.args: [string]);
  (e2.CPS.args: [string, number]);
  (e3.CPS.args: [string, number, string]);
  (e4.CPS.args: [string, number, string, number]);
  (e5.CPS.args: [string, number, string, number, string]);
  (e6.CPS.args: [string, number, string, number, string, number]);
  (e7.CPS.args: [string, number, string, number, string, number, string]);
  (e8.CPS.args: [string, number, string, number, string, number, string, number]);
github flow-typed / flow-typed / definitions / npm / redux-saga_v0.11.x / flow_v0.28.x-v0.37.x / test_redux-saga_0.11.x.js View on Github external
function contextCpsTest() {
  const e0 = cps([context, fn0]);
  const e1 = cps([context, fn1], '1');
  const e2 = cps([context, fn2], '1', 2);
  const e3 = cps([context, fn3], '1', 2, '3');
  const e4 = cps([context, fn4], '1', 2, '3', 4);
  const e5 = cps([context, fn5], '1', 2, '3', 4, '5');
  const e6 = cps([context, fn6], '1', 2, '3', 4, '5', 6);
  const eClass = cps([context2, fn1], '1');
  const eGen = cps([context, g1], '1');

  // Args Test
  (e0.CPS.args: []);
  (e1.CPS.args: [string]);
  (e2.CPS.args: [string, number]);
  (e3.CPS.args: [string, number, string]);
  (e4.CPS.args: [string, number, string, number]);
  (e5.CPS.args: [string, number, string, number, string]);
github flow-typed / flow-typed / definitions / npm / redux-saga_v0.11.x / flow_v0.38.x-v0.67.x / test_redux-saga_0.11.x.js View on Github external
function cpsTest() {
  const e0 = cps(fn0);
  const e1 = cps(fn1, '1');
  const e2 = cps(fn2, '1', 2);
  const e3 = cps(fn3, '1', 2, '3');
  const e4 = cps(fn4, '1', 2, '3', 4);
  const e5 = cps(fn5, '1', 2, '3', 4, '5');
  const e6 = cps(fn6, '1', 2, '3', 4, '5', 6);
  const eClass = cps(fn1, '1');
  const eGen = cps(g1, '1');

  // Args Test
  (e0.CPS.args: []);
  (e1.CPS.args: [string]);
  (e2.CPS.args: [string, number]);
  (e3.CPS.args: [string, number, string]);
  (e4.CPS.args: [string, number, string, number]);
  (e5.CPS.args: [string, number, string, number, string]);
  (e6.CPS.args: [string, number, string, number, string, number]);

  // Fn Test
  (e1.CPS.fn: typeof fn1);
  (e2.CPS.fn: typeof fn2);
  (e3.CPS.fn: typeof fn3);
  (e4.CPS.fn: typeof fn4);
  (e5.CPS.fn: typeof fn5);