1 | import Resource from './resource';
|
2 | declare type Executor = (res: ((value: FollowablePromise) => void), rej: ((reason: any) => any)) => void;
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | export default class FollowablePromise {
|
12 | realPromise: Promise<Resource>;
|
13 | constructor(executor: Executor);
|
14 | /**
|
15 | * The then function maps to a standard then function, as it appears on the
|
16 | * promise.
|
17 | */
|
18 | then(onResolve: (result: any) => Resource | Promise<Resource>, onReject?: (reason: any) => never): Promise<Resource>;
|
19 | /**
|
20 | * The catch function maps to a standard then function, as it appears on the
|
21 | * promise.
|
22 | */
|
23 | catch<T>(onReject: (reason: any) => Promise<T> | T): Promise<Resource | T>;
|
24 | /**
|
25 | * The follow function will wait for this promise to resolve, assume the
|
26 | * resolved value is a Ketting resource and then call 'follow' on it.
|
27 | *
|
28 | * The function returns a Promise that will resolve into the result of that
|
29 | * 'follow' function.
|
30 | *
|
31 | * In practice this means you can chain multiple 'follow' calls.
|
32 | */
|
33 | follow(rel: string, variables?: object): FollowablePromise;
|
34 | /**
|
35 | * The followAll function will wait for this promise to resolve, assume the
|
36 | * resolved value is a Ketting resource and then call 'followAll' on it.
|
37 | *
|
38 | * The function returns a Promise that will resolve into the result of that
|
39 | * 'followAll' function.
|
40 | *
|
41 | * In practice this means you can end a chain of 'follow' calls in the
|
42 | * 'followAll' call.
|
43 | *
|
44 | * It's really the same idea as the follow function, except that you can't
|
45 | * keep on chaining after the followAll, because it resolves in an array of
|
46 | * resources.
|
47 | */
|
48 | followAll(rel: string): Promise<Resource[]>;
|
49 | }
|
50 | export {};
|