Skip to content

Conversation

@k3nsei
Copy link

@k3nsei k3nsei commented Aug 20, 2024

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

When using withComputed store passed to factory there were missing methods.

[x] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

Methods are missing in signalsFactory store.

What is the new behavior?

Methods are available in signalsFactory store.

Does this PR introduce a breaking change?

[x] Yes
[ ] No

Should not have negative effect.

Other information

@netlify
Copy link

netlify bot commented Aug 20, 2024

Deploy Preview for ngrx-io canceled.

Built without sensitive environment variables

Name Link
🔨 Latest commit fbf96c5
🔍 Latest deploy log https://app.netlify.com/sites/ngrx-io/deploys/66c49491efd22e000803ae06

@rainerhahnekamp
Copy link
Contributor

Hey, so as discussed on Discord, withComputed only exposes slices and other computeds.

This is a protection against misuse. You don't want your developers to start implementing logic in withComputed but only in withMethods.

Now, if you have a use case, for having methods in withComputed, starting a discussion about that one first, is the preferred approach.

@k3nsei
Copy link
Author

k3nsei commented Aug 20, 2024

From my perspective Signal Store shouldn't serve a role of "White Knight" to protect against potential "footguns". It could provide warning about potential issues with help of eslint though. But limiting valid usage is just wrong. As functions in JS are also objects so they could carry some state.

@k3nsei
Copy link
Author

k3nsei commented Aug 20, 2024

To be respectful to rules of this project. I created discussion #4500 which should be resolved first before proceeding whit this PR.

@markostanimirovic
Copy link
Member

SignalStore methods are intended to update the state or perform side effects. Since computed signals calculations should be pure, methods should not be used in the withComputed factory.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants