Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

chore(site): refactor deployment values service to react-query#9669

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
BrunoQuaresma merged 5 commits intomainfrombq/refactor-deployment-values-service
Sep 14, 2023

Conversation

BrunoQuaresma
Copy link
Collaborator

No description provided.


exportconstdeploymentConfig=()=>{
return{
queryKey:["deployment","config"],
Copy link
Member

@ParkreinerParkreinerSep 14, 2023
edited
Loading

Choose a reason for hiding this comment

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

Could the query keys be declaredas const? That would not only make sure that they're kept immutable, but also give more precise type information when accessing elements of the key at specific indices

Copy link
Member

@ParkreinerParkreinerSep 14, 2023
edited
Loading

Choose a reason for hiding this comment

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

I don't know if this would cause the compiler to flag anything, though. I'd mainly be worried about type mismatches betweenreadonly arrays with normal arrays

Copy link
CollaboratorAuthor

Choose a reason for hiding this comment

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

I think they could be but I don't see to much value on doing that honestly, what use case you are thinking of?

Copy link
Member

@ParkreinerParkreinerSep 14, 2023
edited
Loading

Choose a reason for hiding this comment

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

Yeah, I'm looking at the code again, and I think it has limited value here, just because all the values are strings. I think I generally default to this approach, but it's most useful when you have a key array that mixes different types.

constkey1=["workspaces",23,{running:true}];constkey2=["workspaces",23,{running:true}]asconst;// Inferred as type (string | number | { running: boolean }), because array is arbitrary-lengthconstuserId1=key1[1];// Inferred as type number, because key2 is a fixed-length, immutable tupleconstuserId2=key2[1];

It's more friendly to thenoUncheckedIndexedAccess compiler setting, too

Copy link
CollaboratorAuthor

Choose a reason for hiding this comment

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

I see, but I don't see we using something similar like this - accessing the keys directly - so I think we could wait until it becomes an issue or provide more value. Wdyt? But if you feel strong about that, we can do it for all the query keys, I just would do in a diff PR (since it is going to change non related queries as well).

Copy link
Member

Choose a reason for hiding this comment

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

No, I'm okay with keeping things as-is. There have been cases where I've passed the query key into the function to construct which API endpoint and which parameters to use, and theas const declarations would help with that, but if there hasn't been a need for that pattern, then I agree with you – it's going to have limited use

Copy link
Member

@ParkreinerParkreiner left a comment

Choose a reason for hiding this comment

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

I think all of this makes sense. My comments mainly deal with clarifying questions for myself.


exportconstdeploymentConfig=()=>{
return{
queryKey:["deployment","config"],
Copy link
Member

@ParkreinerParkreinerSep 14, 2023
edited
Loading

Choose a reason for hiding this comment

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

I don't know if this would cause the compiler to flag anything, though. I'd mainly be worried about type mismatches betweenreadonly arrays with normal arrays

};

exportconstDeploySettingsLayout:FC=()=>{
const[state]=useMachine(deploymentConfigMachine);
Copy link
Member

@ParkreinerParkreinerSep 14, 2023
edited
Loading

Choose a reason for hiding this comment

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

Still need to learn XState, but I'm guessing that this line was meant to expose the machine as a read-only value?

Copy link
CollaboratorAuthor

Choose a reason for hiding this comment

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

it is to instantiate a machine

Copy link
Member

@ParkreinerParkreinerSep 14, 2023
edited
Loading

Choose a reason for hiding this comment

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

Okay, so it creates the new machine instance, but it's bound as local state for that given component, right? it's not quite a Redux setup where there's only ever one store, and the components selectively subscribe to it?

Copy link
CollaboratorAuthor

Choose a reason for hiding this comment

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

Yes, it is bound to the component, in this case to the DashboardLayout

@BrunoQuaresmaBrunoQuaresma removed the request for review fromaslilacSeptember 14, 2023 21:02
Copy link
Member

@ParkreinerParkreiner left a comment

Choose a reason for hiding this comment

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

Looks really good!


exportconstdeploymentConfig=()=>{
return{
queryKey:["deployment","config"],
Copy link
Member

Choose a reason for hiding this comment

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

No, I'm okay with keeping things as-is. There have been cases where I've passed the query key into the function to construct which API endpoint and which parameters to use, and theas const declarations would help with that, but if there hasn't been a need for that pattern, then I agree with you – it's going to have limited use

@BrunoQuaresmaBrunoQuaresma merged commit3b088a5 intomainSep 14, 2023
@BrunoQuaresmaBrunoQuaresma deleted the bq/refactor-deployment-values-service branchSeptember 14, 2023 21:49
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsSep 14, 2023
@BrunoQuaresma
Copy link
CollaboratorAuthor

Related to#9598

Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

@ParkreinerParkreinerParkreiner approved these changes

Assignees

@BrunoQuaresmaBrunoQuaresma

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@BrunoQuaresma@Parkreiner

[8]ページ先頭

©2009-2025 Movatter.jp