-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature(code/frontend): cancel file blob and directory commits reques…
…t if outdated (#43348)
- Loading branch information
WangQianliang
authored
Aug 18, 2019
1 parent
d28690d
commit 6c28612
Showing
3 changed files
with
45 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { take, spawn } from 'redux-saga/effects'; | ||
import { Action } from 'redux-actions'; | ||
|
||
function* cancelRequest(action: Action<any>, abortController: AbortController) { | ||
yield take(action.type); | ||
abortController.abort(); | ||
} | ||
|
||
export const singletonRequestSaga = (saga: any) => | ||
function*(action: Action<any>) { | ||
const abortController = new AbortController(); | ||
const task = yield spawn(cancelRequest, action, abortController); | ||
yield spawn(saga, action, abortController.signal, task); | ||
}; |