-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(signals): use
Injector
of rxMethod
instance caller
Ensure that an instance of `rxMethod` uses the `Injector` of the caller where the instance was invoked, rather than the injector of the node where `rxMethod` was created. This change addresses a potential memory leak where a `SignalStore` method, generated by `rxMethod` and provided at the root level, continues to track a signal via its `effect` using the `RootInjector`. In cases where the component calling the method is destroyed, the `Signal` remains tracked, leading to unintended behavior and memory retention. With this commit, `rxMethod` now prioritizes the injector of the instance caller, falling back to the creator's injector only if no injection context exists. Additionally, a custom injector can be provided by the caller and will take precedence when specified. For `Observable`, since it has a different completion mechanism, the instance caller is still responsible for handling unsubscription or completion.
- Loading branch information
1 parent
1f7f740
commit 7286585
Showing
2 changed files
with
155 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters