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

feat(signals): add signalStore and signalStoreFeature #4049

Merged
merged 2 commits into from
Sep 22, 2023

Conversation

markostanimirovic
Copy link
Member

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[ ] 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?

Closes #4000

What is the new behavior?

signalStore and signalStoreFeature functions are added to the @ngrx/signals package.

Does this PR introduce a breaking change?

[ ] Yes
[x] No

@netlify
Copy link

netlify bot commented Sep 18, 2023

Deploy Preview for ngrx-io canceled.

Name Link
🔨 Latest commit f1eda7f
🔍 Latest deploy log https://app.netlify.com/sites/ngrx-io/deploys/650c98e88ee4e2000818c683

Copy link
Member

@brandonroberts brandonroberts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@timdeschryver timdeschryver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the different files for each feature 🤩
As mentioned earlier, it seems like my WebStorm fails to infer some types, while VSCode can.

image

);
}

function withCustomFeatureWithInput<_>() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this generic has a meaning?

Suggested change
function withCustomFeatureWithInput<_>() {
function withCustomFeatureWithInput() {

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed a weird typing bug when custom features with input are used in complex use cases.

Here is the reproduction. If we remove <_> from withY, the compilation error will be thrown in SignalStores that use withY feature although the generic isn't used anywhere. 👀

This is a rare case, but I'll document this behavior and there will be a recommendation in the docs.

Comment on lines +37 to +38
state: type<{ foo: string }>(),
signals: type<{ s: Signal<number> }>(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got a question about the usage of type.
If I understand this correctly, the type is used here to make the store typesafe? In this case, this feature expects that it's used within a store that has a foo state property, and a s signal property.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly!

@timdeschryver timdeschryver merged commit 0010281 into main Sep 22, 2023
5 checks passed
@timdeschryver timdeschryver deleted the feat/signals/signal-store branch September 22, 2023 12:15
@timdeschryver
Copy link
Member

Congrats on closing #4000! 🚀

@Maciejlys
Copy link

When can we expect release of this? I assume this will be a npm package ngrx/signals?

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.

@ngrx/signals: Add initial signalStore implementation
4 participants