You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(signals): warn when reactive method runs with source injector (#4742)
Closes#4726
Co-authored-by: Tim Deschryver <28659384+timdeschryver@users.noreply.github.com>
Co-authored-by: Marko Stanimirović <markostanimirovic95@gmail.com>
Copy file name to clipboardExpand all lines: projects/ngrx.io/content/guide/signals/rxjs-integration.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -208,7 +208,7 @@ export class BooksComponent implements OnInit {
208
208
The cleanup behavior of reactive methods differs when they're created and called across different injector hierarchies.
209
209
210
210
If the reactive method is called within the descendant injection context, the call will be automatically cleaned up when the descendant injector is destroyed.
211
-
However, when the call is made outside of the descendant injection context, it's necessary to explicitly provide the descendant injector reference to ensure proper cleanup.
211
+
However, when the call is made outside of the descendant injection context, it's necessary to explicitly provide the descendant injector reference to ensure proper cleanup. Otherwise, the cleanup occurs when the ascendant injector where the reactive method is initialized gets destroyed.
@@ -241,7 +241,7 @@ export class NumbersComponent implements OnInit {
241
241
242
242
<divclass="alert is-important">
243
243
244
-
If the injector is not provided when calling the reactive method outside of current injection context, the cleanup occurs when reactive method is destroyed.
244
+
If the injector is not provided when calling the reactive method with a signal or observable outside the injection context, a warning message about a potential memory leak is displayed in development mode.
245
245
246
246
</div>
247
247
@@ -322,4 +322,4 @@ export class NumbersComponent implements OnInit {
Copy file name to clipboardExpand all lines: projects/ngrx.io/content/guide/signals/signal-method.md
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -91,6 +91,12 @@ export class NumbersComponent implements OnInit {
91
91
92
92
Here, the `effect` outlives the component, which would produce a memory leak.
93
93
94
+
<divclass="alert is-important">
95
+
96
+
If an injector is not provided when a method generated by `signalMethod` is called with a signal outside the injection context, a warning message about a potential memory leak is displayed in development mode.
97
+
98
+
</div>
99
+
94
100
## Manual Cleanup
95
101
96
102
When a `signalMethod` is created in an ancestor injection context, it's necessary to explicitly provide the caller injector to ensure proper cleanup:
0 commit comments