Use IAbortable
This commit is contained in:
parent
ea2842f37f
commit
8fcfd713e0
2 changed files with 3 additions and 4 deletions
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
interface IAbortable {
|
export interface IAbortable {
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,12 +17,11 @@ limitations under the License.
|
||||||
|
|
||||||
import {ConnectionError} from "../matrix/error.js";
|
import {ConnectionError} from "../matrix/error.js";
|
||||||
import type {Timeout} from "../platform/web/dom/Clock.js"
|
import type {Timeout} from "../platform/web/dom/Clock.js"
|
||||||
|
import type {IAbortable} from "./AbortableOperation";
|
||||||
|
|
||||||
type TimeoutCreator = (ms: number) => Timeout;
|
type TimeoutCreator = (ms: number) => Timeout;
|
||||||
// ts-todo: export type RequestResult from fetch.js? we'll need to wait until it's typescript though.
|
|
||||||
type Abortable = { abort(): void; [key: string]: any };
|
|
||||||
|
|
||||||
export function abortOnTimeout(createTimeout: TimeoutCreator, timeoutAmount: number, requestResult: Abortable, responsePromise: Promise<Response>) {
|
export function abortOnTimeout(createTimeout: TimeoutCreator, timeoutAmount: number, requestResult: IAbortable, responsePromise: Promise<Response>) {
|
||||||
const timeout = createTimeout(timeoutAmount);
|
const timeout = createTimeout(timeoutAmount);
|
||||||
// abort request if timeout finishes first
|
// abort request if timeout finishes first
|
||||||
let timedOut = false;
|
let timedOut = false;
|
||||||
|
|
Reference in a new issue