當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript effects.fork函數代碼示例

本文整理匯總了TypeScript中redux-saga/effects.fork函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript fork函數的具體用法?TypeScript fork怎麽用?TypeScript fork使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了fork函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: apiSaga

export function* apiSaga() {
  const { apiHost }: ApplicationState = yield select();
  yield fork(getComponents);
  yield fork(syncWorkspaceState);
  yield fork(createSocketIOSaga(io(apiHost)));
  yield fork(handlePingPong);
}
開發者ID:cryptobuks,項目名稱:tandem,代碼行數:7,代碼來源:api.ts

示例2: authFlow

export function* authFlow() {
  yield fork(watchStorage);
  yield fork(redirectOnAuth);

  while (true) {
    const token = auth.retrieveToken();

    if (token) {
      const state = yield select(state => state.auth);

      if (!state || state.token.toString() !== token.toString()) {
        yield put(signinSuccess(token, false));
      }

      yield call(watchExpiration, token.expiresIn);
    } else {
      yield call(purgeToken, false);
    }

    const { signin, signup } = yield race({ signin: take(SIGNIN), signup: take(SIGNUP), overwise: take(SIGNIN_SUCCESS) });

    if (signin) {
      yield fork(submitSigninForm, signin.resolve, signin.reject);
      yield call(createToken, signin);
      continue;
    }

    if (signup) {
      yield fork(submitSignupForm, signup.resolve, signup.reject);
      yield call(createUser, signup);
      continue;
    }
  }
}
開發者ID:rosendi,項目名稱:figure,代碼行數:34,代碼來源:auth.ts

示例3: mainSaga

export function* mainSaga() {
  yield fork(ipcSaga);
  yield fork(screenshotsSaga);
  yield fork(expresssServerSaga);
  yield fork(routesSaga);
  yield fork(uriWatcherSaga);
}
開發者ID:cryptobuks,項目名稱:tandem,代碼行數:7,代碼來源:index.ts

示例4: rootSaga

export function* rootSaga(): any {
	yield all([
		fork(posts.postsSaga),
		fork(tags.tagsSaga),
		fork(summary.summarySaga),
	]);
}
開發者ID:weiweiwitch,項目名稱:third-lab,代碼行數:7,代碼來源:sagas.ts

示例5: root

export default function* root() {
  yield [
    fork(githubGistsSaga),
    fork(githubStarsSaga),
    fork(starwarsFilmsSaga),
    fork(authSaga),
  ];
}
開發者ID:happylinks,項目名稱:vortigern,代碼行數:8,代碼來源:index.ts

示例6: formsFlow

export function* formsFlow() {
  yield [
    fork(watchCreate),
    fork(watchUpdate),
    fork(watchDelete),
    fork(watchIndexRedirect),
    fork(streamForms),
  ]
}
開發者ID:rosendi,項目名稱:figure,代碼行數:9,代碼來源:forms.ts

示例7: screenshotsSaga

export function* screenshotsSaga() {
  yield spawn(handleTakingScreesnshots);
  yield fork(handleNewScreenshot);
  yield fork(handleSavedScreenshot);
  yield fork(cleanupOldScreenshots);

  // last thing to launch
  yield fork(openHeadlessBrowser);
}
開發者ID:cryptobuks,項目名稱:tandem,代碼行數:9,代碼來源:screenshots.ts

示例8: put

 return function* () {
     yield put(languagesActions.set([
         { id: 'english', caption: 'English' },
         { id: 'bulgarian', caption: 'Български (Bulgarian)' },
         { id: 'czech', caption: 'čeština (Czech)' },
         { id: 'russian', caption: 'Русский (Russian)' },
     ]))
     yield fork(authSaga, history, authApi, usersApi)
     yield fork(router, history, routeSettings)
 }
開發者ID:steam-react,項目名稱:steam,代碼行數:10,代碼來源:index.ts

示例9: rootSaga

export default function* rootSaga () {
  yield all([
    takeEvery('search/query', requestSearch),
    takeEvery('search/activeTab', requestSearch),
    fork(syncSearchSongs),
    fork(syncSearchPlaylists),
    fork(syncSearchArtist),
    fork(syncSearchAlbums)
  ])
}
開發者ID:czb128abc,項目名稱:gouqi,代碼行數:10,代碼來源:search.ts

示例10: countdownFlow

function* countdownFlow() {
  const tasks: StringKeyValuePair = {};

  while (true) {
    const action = yield take([
      actions.pause,
      actions.remove,
      actions.reset,
      actions.start,
      actions.stop,
    ]);

    const countdownId = action.payload;

    if (hasSameActionType(action, actions.pause)) {
      yield cancel(tasks[countdownId]);

      const countdown: Countdown = yield select(({ countdowns }: State) =>
        countdowns.find((c: Countdown) => c.id === countdownId),
      );

      yield put(actions.update(countdownId, {
        paused: true,
        alarmSoundEnabled: countdown.milliseconds === 0,
      }));
    }

    if (hasSameActionType(action, actions.remove)) {
      if (tasks[countdownId]) {
        yield cancel(tasks[countdownId]);
      }
    }

    if (hasSameActionType(action, actions.reset)) {
      yield cancel(tasks[countdownId]);

      const countdown: Countdown = yield select(({ countdowns }: State) =>
        countdowns.find((c: Countdown) => c.id === countdownId),
      );

      if (!countdown.paused) {
        tasks[countdownId] = yield fork(countdownInterval, countdownId);
      }
    }

    if (hasSameActionType(action, actions.start)) {
      tasks[countdownId] = yield fork(countdownInterval, countdownId);
    }

    if (hasSameActionType(action, actions.stop)) {
      yield put(actions.update(countdownId, { alarmSoundEnabled: false }));
    }
  }
}
開發者ID:danilobjr,項目名稱:PomodoroTimer,代碼行數:54,代碼來源:countdowns.ts


注:本文中的redux-saga/effects.fork函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。