Skip to content

Commit 6659135

Browse files
Merge pull request #168 from universal-ember/update-getPromiseState-docs-part-two
Update docs
2 parents e1f7076 + 1c42526 commit 6659135

File tree

1 file changed

+35
-7
lines changed

1 file changed

+35
-7
lines changed

reactiveweb/src/get-promise-state.ts

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -206,32 +206,60 @@ export type GetPromiseStateInput<Value> =
206206
* 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)
207207
* namely, the `getPromiseState` in this library (reactiveweb) does not support futures, cancellation, or anything else specific to warp-drive.
208208
*
209+
*
210+
* --------------
211+
212+
_comparison of pure capability_
209213
210214
| . | reactiveweb | @warpdrive/ember |
211215
| - | ----------- | ---------------- |
212216
| use in module state[^module-state] | ✅ | ✅ |
213217
| use in a getter[^cached-getter] | ✅ | ✅ |
214218
| usable in template | ✅ | ✅ |
215219
| immediate has resolved value for resolved promise | ✅ | ✅ |
216-
| invokes a passed function automatically | ✅ | ❌ |
217-
| avoids addons using private APIs | ✅ | ❌[^private-apis] |
218220
| test waiter integration | ✅ | ✅ |
219-
| no dependencies[^no-dependencies] | ✅[^ember-resources] | ❌ |
220-
| simple state return[^state-compare] | ✅ | ❌[^wd-aliases] |
221+
| can be used without build | ✅ | ❌[^warp-drive-no-build] |
222+
| allows prepopulation of result cache by 3rd party | ❌ | ✅ |
223+
| discriminated states (helpful for TS) | ❌[^needs-work] | ✅ |
224+
| align with [allSettled's return value](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/allSettled#return_value) | ❌[^needs-work] | ✅ |
225+
226+
[^warp-drive-no-build]: the warp-drive team is interested in this work, and wants to make REPLs and CDNs easier as well
221227
222228
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).
224230
225231
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.
226232
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+
227256
228257
[^module-state]: `getPromiseState(promise);`
229258
[^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.
231259
[^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.
232260
[^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`.
233261
[^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).
235263
*
236264
*/
237265
export function getPromiseState<Value, Result = ResolvedValueOf<Value>>(

0 commit comments

Comments
 (0)