@warp-drive/ember 0.0.0-beta.1 → 0.0.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -4
- package/dist/index.js +388 -148
- package/dist/index.js.map +1 -1
- package/package.json +43 -32
- package/unstable-preview-types/-private/await.d.ts.map +1 -1
- package/unstable-preview-types/-private/request.d.ts +120 -2
- package/unstable-preview-types/-private/request.d.ts.map +1 -1
- package/unstable-preview-types/index.d.ts +2 -2
|
@@ -4,6 +4,8 @@ declare module '@warp-drive/ember/-private/request' {
|
|
|
4
4
|
import type { StoreRequestInput } from '@ember-data/store';
|
|
5
5
|
import type Store from '@ember-data/store';
|
|
6
6
|
import type { RequestLoadingState, RequestState } from '@warp-drive/ember/-private/request-state.ts';
|
|
7
|
+
type AutorefreshBehaviorType = 'online' | 'interval' | 'invalid';
|
|
8
|
+
type AutorefreshBehaviorCombos = true | AutorefreshBehaviorType | `${AutorefreshBehaviorType},${AutorefreshBehaviorType}` | `${AutorefreshBehaviorType},${AutorefreshBehaviorType},${AutorefreshBehaviorType}`;
|
|
7
9
|
type ContentFeatures<RT> = {
|
|
8
10
|
isOnline: boolean;
|
|
9
11
|
isHidden: boolean;
|
|
@@ -18,11 +20,12 @@ declare module '@warp-drive/ember/-private/request' {
|
|
|
18
20
|
request?: Future<RT>;
|
|
19
21
|
query?: StoreRequestInput<T, RT>;
|
|
20
22
|
store?: Store;
|
|
21
|
-
autorefresh?:
|
|
23
|
+
autorefresh?: AutorefreshBehaviorCombos;
|
|
22
24
|
autorefreshThreshold?: number;
|
|
23
25
|
autorefreshBehavior?: 'refresh' | 'reload' | 'policy';
|
|
24
26
|
};
|
|
25
27
|
Blocks: {
|
|
28
|
+
idle: [];
|
|
26
29
|
loading: [state: RequestLoadingState];
|
|
27
30
|
cancelled: [
|
|
28
31
|
error: StructuredErrorDocument,
|
|
@@ -44,25 +47,139 @@ declare module '@warp-drive/ember/-private/request' {
|
|
|
44
47
|
always: [state: RequestState<T, RT>];
|
|
45
48
|
};
|
|
46
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* The `<Request>` component is a powerful tool for managing data fetching and
|
|
52
|
+
* state in your Ember application. It provides declarative reactive control-flow
|
|
53
|
+
* for managing requests and state in your application.
|
|
54
|
+
*
|
|
55
|
+
* @typedoc
|
|
56
|
+
*/
|
|
47
57
|
export class Request<T, RT> extends Component<RequestSignature<T, RT>> {
|
|
48
58
|
/**
|
|
59
|
+
* The store instance to use for making requests. If contexts are available, this
|
|
60
|
+
* will be the `store` on the context, else it will be the store service.
|
|
61
|
+
*
|
|
49
62
|
* @internal
|
|
50
63
|
*/
|
|
51
64
|
_store: Store;
|
|
65
|
+
/**
|
|
66
|
+
* Whether the browser reports that the network is online.
|
|
67
|
+
*
|
|
68
|
+
* @internal
|
|
69
|
+
*/
|
|
52
70
|
isOnline: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Whether the browser reports that the tab is hidden.
|
|
73
|
+
*
|
|
74
|
+
* @internal
|
|
75
|
+
*/
|
|
53
76
|
isHidden: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Whether the component is currently refreshing the request.
|
|
79
|
+
*
|
|
80
|
+
* @internal
|
|
81
|
+
*/
|
|
54
82
|
isRefreshing: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* The most recent blocking request that was made, typically
|
|
85
|
+
* the result of a reload.
|
|
86
|
+
*
|
|
87
|
+
* This will never be the original request passed as an arg to
|
|
88
|
+
* the component.
|
|
89
|
+
*
|
|
90
|
+
* @internal
|
|
91
|
+
*/
|
|
55
92
|
_localRequest: Future<RT> | undefined;
|
|
93
|
+
/**
|
|
94
|
+
* The most recent request that was made, typically due to either a
|
|
95
|
+
* reload or a refresh.
|
|
96
|
+
*
|
|
97
|
+
* This will never be the original request passed as an arg to
|
|
98
|
+
* the component.
|
|
99
|
+
*
|
|
100
|
+
* @internal
|
|
101
|
+
*/
|
|
56
102
|
_latestRequest: Future<RT> | undefined;
|
|
103
|
+
/**
|
|
104
|
+
* The time at which the network was reported as offline.
|
|
105
|
+
*
|
|
106
|
+
* @internal
|
|
107
|
+
*/
|
|
57
108
|
unavailableStart: number | null;
|
|
109
|
+
intervalStart: number | null;
|
|
110
|
+
nextInterval: number | null;
|
|
111
|
+
invalidated: boolean;
|
|
112
|
+
isUpdating: boolean;
|
|
113
|
+
/**
|
|
114
|
+
* The event listener for network status changes,
|
|
115
|
+
* cached to use the reference for removal.
|
|
116
|
+
*
|
|
117
|
+
* @internal
|
|
118
|
+
*/
|
|
58
119
|
onlineChanged: (event: Event) => void;
|
|
120
|
+
/**
|
|
121
|
+
* The event listener for visibility status changes,
|
|
122
|
+
* cached to use the reference for removal.
|
|
123
|
+
*
|
|
124
|
+
* @internal
|
|
125
|
+
*/
|
|
59
126
|
backgroundChanged: (event: Event) => void;
|
|
127
|
+
/**
|
|
128
|
+
* The last request passed as an arg to the component,
|
|
129
|
+
* cached for comparison.
|
|
130
|
+
*
|
|
131
|
+
* @internal
|
|
132
|
+
*/
|
|
60
133
|
_originalRequest: Future<RT> | undefined;
|
|
134
|
+
/**
|
|
135
|
+
* The last query passed as an arg to the component,
|
|
136
|
+
* cached for comparison.
|
|
137
|
+
*
|
|
138
|
+
* @internal
|
|
139
|
+
*/
|
|
61
140
|
_originalQuery: StoreRequestInput<T, RT> | undefined;
|
|
141
|
+
_subscription: object | null;
|
|
142
|
+
_subscribedTo: object | null;
|
|
62
143
|
constructor(owner: unknown, args: RequestSignature<T, RT>['Args']);
|
|
144
|
+
beginPolling(): Promise<void>;
|
|
145
|
+
get isIdle(): boolean;
|
|
146
|
+
get autorefreshTypes(): Set<AutorefreshBehaviorType>;
|
|
147
|
+
scheduleInterval(): Promise<void>;
|
|
148
|
+
clearInterval(): void;
|
|
149
|
+
updateSubscriptions(): void;
|
|
150
|
+
removeSubscriptions(): void;
|
|
151
|
+
/**
|
|
152
|
+
* Install the event listeners for network and visibility changes.
|
|
153
|
+
* This is only done in browser environments with a global `window`.
|
|
154
|
+
*
|
|
155
|
+
* @internal
|
|
156
|
+
*/
|
|
63
157
|
installListeners(): void;
|
|
64
|
-
|
|
158
|
+
/**
|
|
159
|
+
* If the network is online and the tab is visible, either reload or refresh the request
|
|
160
|
+
* based on the component's configuration and the requested update mode.
|
|
161
|
+
*
|
|
162
|
+
* Valid modes are:
|
|
163
|
+
*
|
|
164
|
+
* - `'reload'`: Force a reload of the request.
|
|
165
|
+
* - `'refresh'`: Refresh the request in the background.
|
|
166
|
+
* - `'policy'`: Make the request, letting the store's configured CachePolicy decide whether to reload, refresh, or do nothing.
|
|
167
|
+
* - `undefined`: Make the request using the component's autorefreshBehavior setting if the autorefreshThreshold has passed.
|
|
168
|
+
*
|
|
169
|
+
* @internal
|
|
170
|
+
*/
|
|
171
|
+
maybeUpdate(mode?: 'reload' | 'refresh' | 'policy' | 'invalidated', silent?: boolean): void;
|
|
172
|
+
/**
|
|
173
|
+
* Retry the request, reloading it from the server.
|
|
174
|
+
*
|
|
175
|
+
* @internal
|
|
176
|
+
*/
|
|
65
177
|
retry: () => Promise<void>;
|
|
178
|
+
/**
|
|
179
|
+
* Refresh the request, updating it in the background.
|
|
180
|
+
*
|
|
181
|
+
* @internal
|
|
182
|
+
*/
|
|
66
183
|
refresh: () => Promise<void>;
|
|
67
184
|
get errorFeatures(): {
|
|
68
185
|
isHidden: boolean;
|
|
@@ -71,6 +188,7 @@ declare module '@warp-drive/ember/-private/request' {
|
|
|
71
188
|
};
|
|
72
189
|
get contentFeatures(): ContentFeatures<RT>;
|
|
73
190
|
willDestroy(): void;
|
|
191
|
+
get _request(): Future<RT>;
|
|
74
192
|
get request(): Future<RT>;
|
|
75
193
|
get store(): Store;
|
|
76
194
|
get reqState(): RequestState<T, RT>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/-private/request.ts"],"names":[],"mappings":"AACA,OAAO,SAAS,MAAM,oBAAoB,CAAC;AA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IG;IACH,KAAK,sBAGH;IAEF;;;;OAIG;IACH,OAAO,sBAGL;IAEF,IACI,aAAa;;;;MAMhB;IAED,IACI,eAAe,wBAiBlB;IAED,WAAW;IAiBX,IACI,QAAQ,IAAI,MAAM,CAAC,EAAE,CAAC,CAmBzB;IAED,IACI,OAAO,IAAI,MAAM,CAAC,EAAE,CAAC,CAIxB;IAED,IAAI,KAAK,IAAI,KAAK,CASjB;IAED,IAAI,QAAQ,wBAEX;IAED,IAAI,MAAM,IACuB,EAAE,CAClC;CAuCF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/// <reference path="./-private/request.d.ts" />
|
|
2
|
-
/// <reference path="./-private/promise-state.d.ts" />
|
|
3
1
|
/// <reference path="./-private/request-state.d.ts" />
|
|
4
2
|
/// <reference path="./-private/await.d.ts" />
|
|
3
|
+
/// <reference path="./-private/promise-state.d.ts" />
|
|
4
|
+
/// <reference path="./-private/request.d.ts" />
|
|
5
5
|
declare module '@warp-drive/ember' {
|
|
6
6
|
export { getRequestState } from '@warp-drive/ember/-private/request-state';
|
|
7
7
|
export { getPromiseState } from '@warp-drive/ember/-private/promise-state';
|