Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

signalMethod cleans up watcher after first effect run #4644

Open
2 tasks
davdev82 opened this issue Dec 26, 2024 · 2 comments
Open
2 tasks

signalMethod cleans up watcher after first effect run #4644

davdev82 opened this issue Dec 26, 2024 · 2 comments

Comments

@davdev82
Copy link

davdev82 commented Dec 26, 2024

Which @ngrx/* package(s) are the source of the bug?

signals

Minimal reproduction of the bug/regression with instructions

The Cleanup callback registration as shown https://github.com/ngrx/platform/blob/34d18af5520bc671d9e7b3b4fda038357517f7a3/modules/signals/src/signal-method.ts#L41in the signalMethod effect gets executed on every effect run.

This would remove the effect watcher entry from the Watchers list after the first effect run and therefore will remove the capability to destroy all the watchers in one go via the signalMethodFn.destroy() call.

Expected behavior

We dont need to register a cleanup callback for the underlying effect used to track the signal when calling signalMethod. This will ensure that a call to signalMethodFn.destroy() will work correctly and therefore will destroy all the effects that are created via the signalMethod call

Versions of NgRx, Angular, Node, affected browser(s) and operating system(s)

NgRx - 19.0.0

Other information

Reproduction - https://stackblitz.com/edit/github-nagwuftn?file=src%2Fmain.ts.
As you can see even after destroying the signalMethod the logging continues in the console.

I would be willing to submit a PR to fix this issue

  • Yes
  • No
@rainerhahnekamp
Copy link
Contributor

Good catch @davdev82. Do you want to provide the fix as well?

@davdev82
Copy link
Author

@rainerhahnekamp sure can do. Will need some guidance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants