本文整理匯總了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;
});
}
示例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);
}
}
});
示例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);
}
});
示例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);
}();
示例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));
}
}
}
}