@warp-drive/ember 0.0.0-alpha.7 → 0.0.0-alpha.70

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 CHANGED
@@ -22,6 +22,14 @@
22
22
  pnpm install @warp-drive/ember
23
23
  ```
24
24
 
25
+ **Tagged Releases**
26
+
27
+ - ![NPM Canary Version](https://img.shields.io/npm/v/%40warp-drive%2Fember/canary?label=@canary&color=FFBF00)
28
+ - ![NPM Beta Version](https://img.shields.io/npm/v/%40warp-drive%2Fember/bet?label=@beta&color=ff00ff)
29
+ - ![NPM Stable Version](https://img.shields.io/npm/v/%40warp-drive%2Fember/latest?label=@latest&color=90EE90)
30
+ - ![NPM LTS Version](https://img.shields.io/npm/v/%40warp-drive%2Fember/lts?label=@lts&color=0096FF)
31
+ - ![NPM LTS-4-12 Version](https://img.shields.io/npm/v/%40warp-drive%2Fember/lts-4-12?label=@lts-4-12&color=bbbbbb)
32
+
25
33
  ## About
26
34
 
27
35
  This library provides reactive utilities for working with promises and requests, building over these primitives to provide functions and components that enable you to build robust performant apps with elegant control flow
@@ -30,10 +38,10 @@ Documentation
30
38
 
31
39
  - [PromiseState](#promisestate)
32
40
  - [getPromiseState](#getpromisestate)
33
- - [\<Await />](#await)
41
+ - [\<Await />](#await-)
34
42
  - [RequestState](#requeststate)
35
43
  - [getRequestState](#getrequeststate)
36
- - [\<Request />](#request)
44
+ - [\<Request />](#request-)
37
45
 
38
46
  ---
39
47
 
@@ -210,6 +218,9 @@ import { Await } from '@warp-drive/ember';
210
218
  </template>
211
219
  ```
212
220
 
221
+ When using the Await component, if no error block is provided and the promise rejects,
222
+ the error will be thrown.
223
+
213
224
  ### RequestState
214
225
 
215
226
  RequestState extends PromiseState to provide a reactive wrapper for a request `Future` which
@@ -297,7 +308,7 @@ import { Request } from '@warp-drive/ember';
297
308
  <template>
298
309
  <Request @request={{@request}}>
299
310
  <:loading as |state|>
300
- <Spinner @percentDone={{state.completeRatio}} />
311
+ <Spinner @percentDone={{state.completedRatio}} />
301
312
  <button {{on "click" state.abort}}>Cancel</button>
302
313
  </:loading>
303
314
 
@@ -312,6 +323,10 @@ import { Request } from '@warp-drive/ember';
312
323
  </template>
313
324
  ```
314
325
 
326
+ When using the Await component, if no error block is provided and the request rejects,
327
+ the error will be thrown. Cancellation errors are not rethrown if no error block or
328
+ cancellation block is present.
329
+
315
330
  - Streaming Data
316
331
 
317
332
  The loading state exposes the download `ReadableStream` instance for consumption
@@ -357,7 +372,36 @@ import { Request } from '@warp-drive/ember';
357
372
  If a request is aborted but no cancelled block is present, the error will be given
358
373
  to the error block to handle.
359
374
 
360
- If no error block is present, the error will be rethrown.
375
+ If no error block is present, the cancellation error will be swallowed.
376
+
377
+ - retry
378
+
379
+ Cancelled and error'd requests may be retried,
380
+ retry will reuse the error, cancelled and loading
381
+ blocks as appropriate.
382
+
383
+ ```gjs
384
+ import { Request } from '@warp-drive/ember';
385
+ import { on } from '@ember/modifier';
386
+
387
+ <template>
388
+ <Request @request={{@request}}>
389
+ <:cancelled as |error state|>
390
+ <h2>The Request Cancelled</h2>
391
+ <button {{on "click" state.retry}}>Retry</button>
392
+ </:cancelled>
393
+
394
+ <:error as |error state|>
395
+ <ErrorForm @error={{error}} />
396
+ <button {{on "click" state.retry}}>Retry</button>
397
+ </:error>
398
+
399
+ <:content as |result|>
400
+ <h1>{{result.title}}</h1>
401
+ </:content>
402
+ </Request>
403
+ </template>
404
+ ```
361
405
 
362
406
  - Reloading states
363
407
 
@@ -426,21 +470,45 @@ import { Request } from '@warp-drive/ember';
426
470
  </template>
427
471
  ```
428
472
 
429
- - AutoRefresh behavior
473
+ - Autorefresh behavior
474
+
475
+ Requests can be made to automatically refresh under any combination of three separate conditions
476
+ by supplying a value to the `@autorefresh` arg.
477
+
478
+ - `online` when a browser window or tab comes back to the foreground after being backgrounded
479
+ or when the network reports as being online after having been offline.
480
+ - `interval` which occurs whenever `@autorefreshThreshold` has been exceeded
481
+ - `invalid` which occurs when the store associated to the request emits an invalidation notification for the request in use.
430
482
 
431
- Requests can be made to automatically refresh when a browser window or tab comes back to the
432
- foreground after being backgrounded.
483
+ These conditions can be used in any combination by providing a comma separated list e.g.
484
+ `interval,invalid`
485
+
486
+ A value of `true` is equivalent to `online,invalid`.
433
487
 
434
488
  ```gjs
435
489
  import { Request } from '@warp-drive/ember';
436
490
 
437
491
  <template>
438
- <Request @request={{@request}} @autoRefresh={{true}}>
492
+ <Request @request={{@request}} @autorefresh={{true}}>
439
493
  <!-- ... -->
440
494
  </Request>
441
495
  </template>
442
496
  ```
443
497
 
498
+ By default, an autorefresh will only occur if the browser was backgrounded or offline for more than
499
+ 30s before coming back available. This amount of time can be tweaked by setting the number of milliseconds
500
+ via `@autorefreshThreshold`.
501
+
502
+ The behavior of the fetch initiated by the autorefresh can also be adjusted by `@autorefreshBehavior`
503
+
504
+ Options are:
505
+
506
+ - `refresh` update while continuing to show the current state.
507
+ - `reload` update and show the loading state until update completes)
508
+ - `policy` (**default**) trigger the request, but let the cache handler decide whether the update should occur or if the cache is still valid.
509
+
510
+ ---
511
+
444
512
  Similarly, refresh could be set up on a timer or on a websocket subscription by using the yielded
445
513
  refresh function and passing it to another component.
446
514
 
@@ -448,7 +516,7 @@ refresh function and passing it to another component.
448
516
  import { Request } from '@warp-drive/ember';
449
517
 
450
518
  <template>
451
- <Request @request={{@request}} @autoRefresh={{true}}>
519
+ <Request @request={{@request}}>
452
520
  <:content as |result state|>
453
521
  <h1>{{result.title}}</h1>
454
522
 
package/addon-main.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  'use strict';
2
2
 
3
- const { addonV1Shim } = require('@embroider/addon-shim');
3
+ const { addonShim } = require('@warp-drive/build-config/addon-shim.cjs');
4
4
 
5
- module.exports = addonV1Shim(__dirname);
5
+ module.exports = addonShim(__dirname);