-
Notifications
You must be signed in to change notification settings - Fork 26.2k
docs(core): Update linked-signal.md #58756
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
Conversation
@@ -61,15 +61,15 @@ In the example above, `selectedOption` always updates back to the first option w | |||
```typescript | |||
@Component({/* ... */}) | |||
export class ShippingMethodPicker { | |||
shippingOptions: Signal<ShippingMethod[]> = getShippingOptions(); | |||
shippingOptions: WritableSignal<ShippingMethod[]> = getShippingOptions(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shippingOptions
could an input, why do you think it should be describe as a writable ? It's not being written to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
without it value is of type unknown, and so can't use .id
in it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're probably answer to the comment I deleted, I got that. I'll investigate if we can improve that. Ideally the generics should be inferred !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah sorry 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
about Writable because it's not an input, now it's impossible to give it a new value
so either make it to equal input, or leave it WritableSignal IMO
I will revert this small change if you insist
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should make it an input
, wdyt @jelbourn ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One of my goals with this doc was is to not explicitly require people understand the component-based signal APIs first.
As to the original suggestion: there's actually nothing wrong with this being a Signal
here. Any signal's value can change; just because this code in the example can't directly change it, doesn't mean the value can't change elsewhere (i.e., somewhere inside getShippingOptions
there's a writable signal, but that function returns it asReadOnly
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@robertIsaac Your commit message needs to be updated to fix the broken lint tests. Can you change that and force push? We can merge it after that's green. |
fix multiple issues with the existing code 1. `shippingOptions` was accessed without `this.` which produces error in realtime 2. the logic in calculating of the item exist or not was not correct since it was comparing the object to the id 3. I'm not sure why, but step 3 fail without stating typing for LinkedSignal, so I added it
@thePunderWoman done |
fix multiple issues with the existing code 1. `shippingOptions` was accessed without `this.` which produces error in realtime 2. the logic in calculating of the item exist or not was not correct since it was comparing the object to the id 3. I'm not sure why, but step 3 fail without stating typing for LinkedSignal, so I added it PR Close #58756
This PR was merged into the repository by commit e495a68. The changes were merged into the following branches: main, 19.0.x |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
fix multiple issues with the existing code sample
shippingOptions
was accessed withoutthis.
which produces error in realtimeWhat is the new behavior?
fixes these issues
Does this PR introduce a breaking change?
Other information