How to use the redux-saga/effects.cps function in redux-saga

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_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);
github barbuza / kebakaran / tests / FirebaseStream-tape.js View on Github external
test('FirebaseStream next', t => {
  const ref = new RefMock();
  const stream = new FirebaseStream(ref);

  t.deepEqual(stream.next(), cps(stream.callback));
  t.end();
});
github barbuza / kebakaran / tests / sagaCb-tape.js View on Github external
function* saga() {
    while (true) {
      actual.push(yield cps(callback));
      yield call(delay);
    }
  }
github stipsan / epic / src / server / sagas / game.js View on Github external
const match = yield select(getMatch)
      const viewerBoard = match.get('viewerBoard')
      const botTurns = getBotTurns(
        botToken,
        match,
        turnsPlayedByBot,
        successfullTurnsPlayedByBot,
        viewerBoard
      )
      console.log('botTurns', botTurns)
      for (let i = 0, len = botTurns.length; i < len; i++) {
        const botTurn = botTurns[i]
        console.log(i, 'botTurn', botTurn)
        const { scores } = yield call(database.saveTurn, botToken, payload.id, botTurn, redis)
        console.log('database.saveTurn', botToken, payload.id, botTurn)
        yield cps([socket.exchange, socket.exchange.publish], `user:${authToken.id}`, {
          type: botTurn.hit ? RECEIVE_HIT : RECEIVE_MISS,
          payload: {
            versusScore: scores[1],
            id: payload.id,
            turn: botTurn,
          }
        })
      }
    }
  } catch ({ name, message }) {
    yield put(socketEmit({ type: failureType, payload: { error: { name, message } } }))
  }
}
github uport-project / uport-mobile / lib / sagas / requests / personalSignRequest.js View on Github external
export function * signData (request) {
  try {
    const signer = yield select(nativeSignerForAddress, request.signer)
    const signature = yield cps(signer.personalSign, request.data)
    const payload = {
      type: 'personalSignResp',
      data: request.data,
      signature
     }
    const target = request.target
    const legacyClient = request.client_id && !request.client_id.match(/did:/)
    const issuer = request.riss || !legacyClient && !request.target.match(/did:/) ? `did:uport:${request.target}` : request.target
    const token = yield call(createToken, target, payload, { expiresIn: false, issuer })
    yield put(updateActivity(request.id, {authorizedAt: new Date().getTime()}))
    return {personalSig: token}
  } catch (e) {
    console.log(e)
  }
}
github uport-project / uport-mobile / lib / sagas / requests / eip712Request.js View on Github external
try {
    const data = request.typedData
    const settings = yield select(networkSettingsForAddress, request.target)

    if (!signerType) {
      signerType = settings.signerType ? settings.signerType : 'keypair'
      console.log('signerType:', signerType)
    }
    const sanitizedData = yield sanitizeData(data)
    const parts = [Buffer.from('1901', 'hex')]

    parts.push(hashStruct('EIP712Domain', data.domain, data.types))
    parts.push(hashStruct(sanitizedData.primaryType, sanitizedData.message, sanitizedData.types))
    const unsigned = Buffer.concat(parts)
    const signer = yield select(nativeSignerForAddress, request.signer)
    const signature = yield cps(signer.signTypedData, unsigned)
    const payload = {
      type: 'eip712Resp',
      request: request.typedData,
      signature
     }

    const target = request.target
    const legacyClient = request.client_id && !request.client_id.match(/did:/)
    const issuer = request.riss || !legacyClient && !request.target.match(/did:/) ? `did:uport:${request.target}` : request.target
    const token = yield call(createToken, target, payload, { expiresIn: false, issuer })
    yield put(updateActivity(request.id, {authorizedAt: new Date().getTime()}))
    return {typedDataSig: token}
  } catch (e) {
    console.log(e)
  }
}
github web-pal / chronos-timetracker / app / renderer / sagas / timer.js View on Github external
activity: {},
        }));
        const screenshotViewerWindowId = yield eff.select(
          getUiState('screenshotViewerWindowId'),
        );
        const screenshotsWin = (
          screenshotViewerWindowId
          && remote.BrowserWindow.fromId(screenshotViewerWindowId)
        );
        if (
          screenshotsWin
          && !screenshotsWin.isDestroyed()
        ) {
          screenshotsWin.destroy();
        }
        yield eff.cps(
          rimraf,
          `${app.getPath('userData')}/screens/`,
        );
        if (
          closeRequest
          && continueStop
        ) {
          if (process.env.NODE_ENV === 'development') {
            window.location.reload();
          } else {
            app.quit();
          }
        }
      } else {
        const allowEmptyComment = yield eff.select(getUiState('allowEmptyComment'));
        const comment = yield eff.select(getUiState('worklogComment'));