@absolutejs/absolute 0.19.0-beta.981 → 0.19.0-beta.982

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.
@@ -1,3 +1,4 @@
1
+ import { DestroyRef } from '@angular/core';
1
2
  import type { Observable, Subscription } from 'rxjs';
2
3
  export type Observer<T> = {
3
4
  next?: (value: T) => void;
@@ -10,11 +11,16 @@ export type Observer<T> = {
10
11
  * collapsed into one call so consumers can't forget the cleanup
11
12
  * operator (the most common Angular memory-leak source).
12
13
  *
13
- * Must be called in an injection context.
14
+ * Prefer calling from an injection context (field initializer or
15
+ * constructor). When called outside one — e.g. from `ngOnInit` —
16
+ * pass the host's `DestroyRef` explicitly as the third argument
17
+ * (capture it via `destroyRef = inject(DestroyRef)` in a field
18
+ * initializer once). Otherwise auto-teardown is dropped and the
19
+ * caller owns the returned `Subscription`.
14
20
  *
15
21
  * Note: this composable handles teardown only — it does not trigger
16
22
  * change detection on emissions. If the observer mutates state that
17
23
  * drives the template, store that state in a `signal()` so updates
18
24
  * propagate in zoneless Angular. */
19
- export declare function useSubscription<T>(observable: Observable<T>, next: (value: T) => void): Subscription;
20
- export declare function useSubscription<T>(observable: Observable<T>, observer: Observer<T>): Subscription;
25
+ export declare function useSubscription<T>(observable: Observable<T>, next: (value: T) => void, destroyRef?: DestroyRef): Subscription;
26
+ export declare function useSubscription<T>(observable: Observable<T>, observer: Observer<T>, destroyRef?: DestroyRef): Subscription;
package/package.json CHANGED
@@ -402,5 +402,5 @@
402
402
  ]
403
403
  }
404
404
  },
405
- "version": "0.19.0-beta.981"
405
+ "version": "0.19.0-beta.982"
406
406
  }