You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: reactiveweb/src/get-promise-state.ts
+35-7Lines changed: 35 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -206,32 +206,60 @@ export type GetPromiseStateInput<Value> =
206
206
* NOTE: This `getPromiseState` is not a replacement for [WarpDrive](https://docs.warp-drive.io/)'s [getRequestState](https://www.npmjs.com/package/@warp-drive/ember#getrequeststate)
207
207
* namely, the `getPromiseState` in this library (reactiveweb) does not support futures, cancellation, or anything else specific to warp-drive.
208
208
*
209
+
*
210
+
* --------------
211
+
212
+
_comparison of pure capability_
209
213
210
214
| . | reactiveweb | @warpdrive/ember |
211
215
| - | ----------- | ---------------- |
212
216
| use in module state[^module-state] | ✅ | ✅ |
213
217
| use in a getter[^cached-getter] | ✅ | ✅ |
214
218
| usable in template | ✅ | ✅ |
215
219
| immediate has resolved value for resolved promise | ✅ | ✅ |
216
-
| invokes a passed function automatically | ✅ | ❌ |
[^warp-drive-no-build]: the warp-drive team is interested in this work, and wants to make REPLs and CDNs easier as well
221
227
222
228
223
-
all in all, they are very similar. The primary use case I had for creating my own is that I wanted dynamic module loading (with import) to be one line (shown in the first example).
229
+
All in all, they are very similar. The primary use case I had for creating my own is that I wanted dynamic module loading (with import) to be one line (shown in the first example).
224
230
225
231
reactiveweb's `getPromiseState` is made primarily for my needs in my own projects, and I don't intend to say anything negative about `@warp-drive`s `getPromiseState` -- I actually took a lot of code from it! it's a good tool.
226
232
233
+
These projects of slightly different goals, so some additional information:
234
+
235
+
_from the perspective of reactiveweb's_ set of goals:
236
+
237
+
| . | reactiveweb | @warpdrive/ember |
238
+
| - | ----------- | ---------------- |
239
+
| invokes a passed function automatically | ✅ | ❌ |
240
+
| simple state return[^state-compare] | ⚠️[^needs-work] | ⚠️ [^warp-drive-pending-deprecations] |
241
+
242
+
[^warp-drive-pending-deprecations]: has pending deprecations, otherwise ✅
243
+
[^needs-work]: This is fixable, and probably with little effort, just needs doing
244
+
245
+
_from the perspective of @warp-drive/core's set of goals_
246
+
247
+
| . | reactiveweb | @warpdrive/core |
248
+
| - | ----------- | ---------------- |
249
+
| has a simple API surface | ❌ [^invokes-functions] | ✅ |
250
+
| no dependencies | ❌ [^ember-resources] | ⚠️[^warp-drive-no-dependencies] |
251
+
252
+
253
+
[^invokes-functions]: `@warp-drive/core` strives for API simplicity, which means few (if any) overloads on its utilities.
254
+
[^warp-drive-no-dependencies]: Does not directly depend on any dependencies, but requires an integration into reactivity (which is technically true for `reactiveweb` as well)
255
+
227
256
228
257
[^module-state]: `getPromiseState(promise);`
229
258
[^cached-getter]: requires a stable reference to a promise. getter itself does not need to be cached.
230
-
[^private-apis]: `@warp-drive/ember` declares an optional peer dependency on `ember-provide-consume-context`, which uses private apis, and we don't want to support usage of private APIs.
231
259
[^no-dependencies]: warp-drive requires a macros config that isn't compatible with "non-config" projects (it's mostly how they generate macros to not gracefully have some behavior if you don't set up their required babel config -- which affects REPL environments (this is solveable via pushing the responsibility to configure babel to the REPLer)). Also, the warp-drive team says this is on their radar, and the'll address it eventually / soon.
232
260
[^ember-resources]: reactiveweb (as a whole) does depend on on ember-resources, but ember-resources itself has no dependencies (for real), and is a very tiny use of a helper manager. Additionally, `getPromiseState` does not depend on `ember-resources`.
233
261
[^wd-aliases]: warp-drive provides _many_ aliases for states, as well as support some extended promise behavior which is not built in to the platform (Futures, etc). This is still good for convenience and compatibility.
234
-
[^state-compare]: in reactiveweb: [State](https://reactive.nullvoxpopuli.com/interfaces/get-promise-state.State.html), and then in `@warp-drive/*`: the [`PromiseState`](https://warp-drive.io/api/@warp-drive/ember/type-aliases/PromiseState) is made of 3 sub types: [PendingPromise](https://warp-drive.io/api/@warp-drive/core/reactive/interfaces/PendingPromise), [ResolvedPromise](https://warp-drive.io/api/@warp-drive/core/reactive/interfaces/ResolvedPromise), and [RejectedPromise](https://warp-drive.io/api/@warp-drive/core/reactive/interfaces/RejectedPromise)
262
+
[^state-compare]: in reactiveweb: [State](https://reactive.nullvoxpopuli.com/interfaces/get-promise-state.State.html), and then in `@warp-drive/*`: the [`PromiseState`](https://warp-drive.io/api/@warp-drive/ember/type-aliases/PromiseState) is made of 3 sub types: [PendingPromise](https://warp-drive.io/api/@warp-drive/core/reactive/interfaces/PendingPromise), [ResolvedPromise](https://warp-drive.io/api/@warp-drive/core/reactive/interfaces/ResolvedPromise), and [RejectedPromise](https://warp-drive.io/api/@warp-drive/core/reactive/interfaces/RejectedPromise). Over time, these will align slightly with [allSettled's return value](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/allSettled#return_value).
0 commit comments