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


TypeScript redux-saga.delay函數代碼示例

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


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

示例1: testDelay

function testDelay() {
  delay(1).then(res => {
    // typings:expect-error
    const e: string = res;
    const r: boolean = res;
  });

  delay(1, 'foo').then(res => {
    // typings:expect-error
    const e: boolean = res;
    const r: string = res;
  });
}
開發者ID:gajus,項目名稱:redux-saga,代碼行數:13,代碼來源:delay.ts

示例2: takeLatest

    yield takeLatest(LoginSuccessType, function* (action: any) {
        if (syncStart || !action.value.result.sync) {
            return;
        }
        syncStart = true;

        yield delay(5000);
        while (true) {
            yield delay(action.value.result.syncInterval * 1000);
            if (GlobalVar.instance.isUserInfoSyncing) {
                continue;
            }
            if (DateUtil.subNowSec(GlobalVar.instance.lastSyncDate) > 5) {
                GlobalVar.instance.isUserInfoSyncing = true;
                const channelAction = syncAction({ type: SyncUserDataType, method: HttpMethod.GET, url: Urls.getUrl(`user/me`), successAction: value => { GlobalVar.instance.isUserInfoSyncing = false; return actionCreator(DateUtil.subNowSec(GlobalVar.instance.lastSyncDate) > 5 ? SyncUserDataSuccessType : EmptyType, { result: value }); } });
                yield put(channelAction);
            }
        }
    });
開發者ID:winken168,項目名稱:Hitchhiker,代碼行數:19,代碼來源:user.ts

示例3: takeLatest

 yield takeLatest(StoreLocalDataType, function* (action: any) {
     try {
         yield delay(1000);
         const state = action.value.state;
         yield call(LocalStore.setState, action.value.userId, { ...state, uiState: { ...state.uiState, syncState: { syncCount: 0, syncItems: [] } } });
     } catch (err) {
         console.log(action.value.state);
         console.error(err);
     }
 });
開發者ID:winken168,項目名稱:Hitchhiker,代碼行數:10,代碼來源:local_data.ts

示例4: function

                return async function() {
                    const tester = expectSaga(queryManagerSaga)
                        .dispatch(refresh(explicitResolveQuery));

                    const testFinished = tester.run();
                    await delay(0);

                    // Query is now in progress, waiting on explicit resolve to
                    // complete. Dispatch two autoRefresh requests, which should
                    // still be serviced.
                    tester
                        .dispatch(autoRefresh(explicitResolveQuery))
                        .dispatch(autoRefresh(explicitResolveQuery));

                    // resolve the query, which should result in the query
                    // immediately being called again due to the auto-refresh
                    // count.
                    await delay(0);
                    resolveQuery();

                    // Dispatch stopAutoRefresh and resolve the query. This
                    // should still result in the query being called again,
                    // because autoRefresh has not been fully decremented.
                    tester
                        .dispatch(stopAutoRefresh(explicitResolveQuery));
                    await delay(0);
                    resolveQuery();

                    // Fully decrement stopAutoRefresh and resolve the query.
                    // Query should not be called again.
                    tester
                        .dispatch(stopAutoRefresh(explicitResolveQuery));
                    await delay(0);
                    resolveQuery();
                    await testFinished;

                    assert.equal(queryCalledCount, 3);
                }();
開發者ID:asubiotto,項目名稱:cockroach,代碼行數:38,代碼來源:saga.spec.ts

示例5: pollingSaga

function* pollingSaga(action: Action<string>) {
  while (true) {
    try {
      const data = yield call(requestStructure, `git:/${action.payload}`);
      yield put(loadStructureSuccess({ path: action.payload!, data }));
    } catch (e) {
      if (e.code && e.code === ServerNotInitialized) {
        yield put(languageServerInitializing());
        yield delay(STRUCTURE_TREE_POLLING_INTERVAL_SEC * 1000);
      } else {
        yield put(loadStructureFailed(e));
      }
    }
  }
}
開發者ID:elastic,項目名稱:kibana,代碼行數:15,代碼來源:structure.ts


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