~sirn/fanboi2

ref: a68873a108d20a6a49a1b6caf374bfb2cf6a94fe fanboi2/assets/app/javascripts/utils/cancellable.ts -rw-r--r-- 362 bytes
a68873a1Kridsada Thanabulpong Coding style cleanups and setup pre-commit hooks (#42) 3 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import { Error } from "./errors";

export interface CancellableToken {
    cancel: (() => void);
}

export class Cancelled implements Error {
    public name = "Cancelled";

    constructor(
        public message: string = "Promise was explicitly aborted by the user.",
    ) {}
}

export class CancelToken implements CancellableToken {
    cancel(): void {}
}