本文整理汇总了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));
}
}
}
}