@context-action/core 0.8.6 → 0.8.8

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
@@ -225,12 +225,21 @@ await actions.dispatch('backgroundTask', data, {
225
225
  queuePriority: 5
226
226
  });
227
227
 
228
- // Execution timeout
229
- await actions.dispatch('timedAction', data, {
230
- timeout: 5000
231
- });
228
+ // Wall-clock timeout (queue wait + retry delay included).
229
+ // Rejects with ActionTimeoutError while the internal operation drains safely.
230
+ await actions.dispatch('timedAction', data, { timeout: 5000 });
232
231
  ```
233
232
 
233
+ The default queue is single-slot. When a handler awaits another dispatch on
234
+ the **same** register, make that nested call explicit with `{ immediate: true }`
235
+ so it can run inside the current queue turn. Likewise, do not set
236
+ `queuePriority` on an awaited nested `dispatchWithResult` call. Independent
237
+ top-level dispatches should keep the queue defaults.
238
+
239
+ Handlers that perform cancellable I/O can observe `controller.signal`. It is
240
+ aborted for caller cancellation, timeout, provider teardown, and register
241
+ shutdown.
242
+
234
243
  ### Result Collection with Strategies
235
244
 
236
245
  ```typescript
@@ -406,7 +415,7 @@ actions.register('riskyOperation', async (data, controller) => {
406
415
  // With retry configuration
407
416
  await actions.dispatch('apiCall', data, {
408
417
  retryOnError: {
409
- maxAttempts: 3,
418
+ maxAttempts: 3, // Total attempts, including the first call
410
419
  delay: 1000
411
420
  }
412
421
  });
@@ -440,8 +449,11 @@ const registry = new ActionRegister({ name: 'MyApp' });
440
449
 
441
450
  // Use the registry...
442
451
 
443
- // Clean up all resources
444
- registry.destroy(); // Cleans up pipelines, guards, queues, stats
452
+ // Begin terminal cleanup. New work is rejected immediately.
453
+ registry.destroy();
454
+
455
+ // Or await proof that started handlers settled and cleanup callbacks ran.
456
+ await registry.destroyAsync();
445
457
  ```
446
458
 
447
459
  ## API Reference
@@ -472,7 +484,8 @@ registry.destroy(); // Cleans up pipelines, guards, queues, stats
472
484
  #### Utility Methods
473
485
  - `getName()` - Get registry name
474
486
  - `isDebugEnabled()` - Check if debug mode is enabled
475
- - `destroy()` - Clean up all resources
487
+ - `destroy()` - Begin terminal cleanup without waiting
488
+ - `destroyAsync()` - Resolve after started handlers settle and cleanup completes
476
489
 
477
490
  ### Configuration Interfaces
478
491
 
@@ -576,7 +589,7 @@ actions.destroy();
576
589
  1. **Use handler IDs** for better debugging and filtering
577
590
  2. **Enable replaceExisting** for React components to prevent duplicates
578
591
  3. **Use immediate: false** (default) to benefit from queue optimizations
579
- 4. **Call destroy()** when registry is no longer needed
592
+ 4. **Await destroyAsync()** when shutdown completion must be guaranteed
580
593
  5. **Use priority filtering** instead of excludeHandlerIds for better performance
581
594
  6. **Cache ActionRegister instances** - don't create new ones frequently
582
595
 
@@ -591,4 +604,4 @@ Apache-2.0
591
604
  - [Vanilla JS Guide](../../docs/en/guide/vanilla-js-guide.md) - Complete vanilla JavaScript guide
592
605
  - [Vanilla JS Examples](../../examples/vanilla-js/) - Interactive examples (counter, todo app)
593
606
  - [React Package](../react/README.md) - React integration
594
- - [Examples](../../example/README.md) - React example application
607
+ - [Examples](../../example/README.md) - React example application