@absolutejs/absolute 0.19.0-beta.963 → 0.19.0-beta.964

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.
@@ -3,7 +3,7 @@ export { ABSOLUTE_HTTP_TRANSFER_CACHE_SKIP_HEADER, buildAbsoluteHttpTransferCach
3
3
  export { createDeterministicRandom, DETERMINISTIC_NOW, DETERMINISTIC_RANDOM, DETERMINISTIC_SEED, provideDeterministicEnv } from './deterministicEnv';
4
4
  export { defineAngularPage } from './page';
5
5
  export { useResource, useSubscription, useTimers } from './composables';
6
- export type { Observer, Resource, ResourceFetcher, ResourceMutator, ResourceOptions } from './composables';
6
+ export type { Observer, Resource, ResourceFetcher, ResourceMutator, ResourceOptions, ResourceStart } from './composables';
7
7
  export { preserveAcrossHmr } from './preserveAcrossHmr';
8
8
  export { Island } from './Island.browser';
9
9
  export { withPendingTask } from './pendingTask';
@@ -1,5 +1,5 @@
1
1
  export { useResource } from './useResource';
2
- export type { Resource, ResourceFetcher, ResourceMutator, ResourceOptions } from './useResource';
2
+ export type { Resource, ResourceFetcher, ResourceMutator, ResourceOptions, ResourceStart } from './useResource';
3
3
  export { useSubscription } from './useSubscription';
4
4
  export type { Observer } from './useSubscription';
5
5
  export { useTimers } from './useTimers';
@@ -1,9 +1,23 @@
1
1
  import { type Signal } from '@angular/core';
2
2
  export type ResourceFetcher<T> = (signal: AbortSignal) => Promise<T>;
3
+ /** Controls the resource's startup behavior.
4
+ *
5
+ * - `'immediate'` (default) — fire the fetcher synchronously at creation;
6
+ * `loading()` starts `true`.
7
+ * - `'pending'` — don't fire the fetcher yet, but render as if a fetch is
8
+ * coming: `loading()` starts `true`. Pair with a manual `refresh()` call
9
+ * from `ngOnInit` (or wherever the dependencies become available). Use
10
+ * this when the fetcher depends on state set after construction (e.g. a
11
+ * route param assigned by the page factory) — it avoids the blank-frame
12
+ * flash you'd get from `'idle'`.
13
+ * - `'idle'` — don't fire the fetcher and don't pretend you will:
14
+ * `loading()` starts `false`. The resource is dormant until `refresh()`
15
+ * or `mutate()` is called.
16
+ */
17
+ export type ResourceStart = 'immediate' | 'pending' | 'idle';
3
18
  export type ResourceOptions = {
4
- /** Run the fetcher immediately on creation. Default: true. Pass
5
- * `false` to defer the first load until `refresh()` is called. */
6
- immediate?: boolean;
19
+ /** When and how the fetcher fires on creation. Default: `'immediate'`. */
20
+ start?: ResourceStart;
7
21
  };
8
22
  export type ResourceMutator<T> = T | null | ((prev: T | null) => T | null);
9
23
  export type Resource<T> = {
@@ -11,7 +25,8 @@ export type Resource<T> = {
11
25
  data: Signal<T | null>;
12
26
  /** Latest rejection reason, or `null` when the resource is healthy. */
13
27
  error: Signal<unknown>;
14
- /** True while a fetch is in flight. */
28
+ /** True while a fetch is in flight, or when `start: 'pending'` was set
29
+ * and `refresh()` hasn't been called yet. */
15
30
  loading: Signal<boolean>;
16
31
  /** Re-runs the fetcher. Any in-flight request is aborted first. */
17
32
  refresh: () => Promise<void>;
@@ -5,7 +5,7 @@ export { createDeterministicRandom, DETERMINISTIC_NOW, DETERMINISTIC_RANDOM, DET
5
5
  export { handleAngularPageRequest } from './pageHandler';
6
6
  export { defineAngularPage } from './page';
7
7
  export { useResource, useSubscription, useTimers } from './composables';
8
- export type { Observer, Resource, ResourceFetcher, ResourceMutator, ResourceOptions } from './composables';
8
+ export type { Observer, Resource, ResourceFetcher, ResourceMutator, ResourceOptions, ResourceStart } from './composables';
9
9
  export { preserveAcrossHmr } from './preserveAcrossHmr';
10
10
  export { withPendingTask } from './pendingTask';
11
11
  export { createTypedIsland } from './createIsland';
package/package.json CHANGED
@@ -402,5 +402,5 @@
402
402
  ]
403
403
  }
404
404
  },
405
- "version": "0.19.0-beta.963"
405
+ "version": "0.19.0-beta.964"
406
406
  }