-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
datasource.ts
30 lines (23 loc) · 1.03 KB
/
datasource.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { Settings, DevSettings } from './settings';
import { IAdapter } from './adapter';
type SuccessFn<T = unknown> = (data: T[]) => void;
type ErrorFn = (error: unknown) => void;
export interface ObservableLike<T = unknown> {
subscribe(next: SuccessFn<T>, error: ErrorFn, complete: () => void): { unsubscribe: () => void };
}
type DSGetCallback<T> = (index: number, count: number, success: SuccessFn<T>, fail?: ErrorFn) => void;
type DSGetObservable<T> = (index: number, count: number) => ObservableLike<T[]>;
type DSGetPromise<T> = (index: number, count: number) => PromiseLike<T[]>;
export type DatasourceGet<T> = DSGetCallback<T> | DSGetObservable<T> | DSGetPromise<T>;
export interface IDatasourceOptional<T = unknown> {
get?: DatasourceGet<T>;
settings?: Settings<T>;
devSettings?: DevSettings;
}
export interface IDatasource<T = unknown> extends IDatasourceOptional<T> {
get: DatasourceGet<T>;
adapter?: IAdapter<T>;
}
export interface IDatasourceConstructed<T = unknown> extends IDatasource<T> {
adapter: IAdapter<T>;
}