本文整理汇总了TypeScript中redux-saga/effects.cancelled函数的典型用法代码示例。如果您正苦于以下问题:TypeScript cancelled函数的具体用法?TypeScript cancelled怎么用?TypeScript cancelled使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cancelled函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: channelSaga
export function* channelSaga(session: ISession): SagaIterator {
const channel: IChannel = yield call(getChannel, session.id, session.mode);
yield call([channel, channel.start], session.id);
yield put(connected());
try {
yield all([
call(channelListenerSaga, channel),
call(channelSenderSaga, session.id, channel)
]);
} finally {
if (yield cancelled()) {
yield call([channel, channel.end]);
}
}
}
示例2: while
return function*(repoUri: RepositoryUri) {
try {
while (true) {
// Delay at the beginning to allow some time for the server to consume the
// queue task.
yield call(delay, REPO_STATUS_POLLING_FREQ_MS);
const repoStatus = yield call(fetchStatus, repoUri);
const keepPolling = yield handleStatus(repoStatus, repoUri);
if (!keepPolling) {
yield put(pollingStopActionFunction(repoUri));
}
}
} finally {
if (yield cancelled()) {
// Do nothing here now.
}
}
};
示例3: timer
function* timer() {
try {
yield put(actions.setBotFrozenTimeout(5e3))
while (true) {
const { delta }: actions.Tick = yield take(actions.A.Tick)
const {
game: { botFrozenTimeout },
}: State = yield select()
if (botFrozenTimeout === 0) {
break
}
const next = botFrozenTimeout - delta
yield put(actions.setBotFrozenTimeout(next <= 0 ? 0 : next))
}
} finally {
if (yield cancelled()) {
yield put(actions.setBotFrozenTimeout(0))
}
}
}
示例4: animateCurtainAndLoadMap
function* animateCurtainAndLoadMap(stage: StageConfig) {
try {
yield put(actions.updateComingStageName(stage.name))
yield put(actions.updateCurtain('stage-enter-curtain', 0))
yield* Timing.tween(f(30), t => put(actions.updateCurtain('stage-enter-curtain', t)))
// 在幕布完全将舞台遮起来的时候载入地图
yield Timing.delay(f(20))
yield put(actions.playSound('stage_start'))
yield put(actions.loadStageMap(stage))
yield Timing.delay(f(20))
yield* Timing.tween(f(30), t => put(actions.updateCurtain('stage-enter-curtain', 1 - t)))
// todo 游戏开始的时候有一个 反色效果
} finally {
if (yield cancelled()) {
// 将幕布隐藏起来
yield put(actions.updateCurtain('stage-enter-curtain', 0))
}
}
}
示例5: testCancelled
function* testCancelled(): SagaIterator {
yield cancelled();
// typings:expect-error
yield cancelled(1);
}