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

types: loose cache types #1937

Closed
wants to merge 1 commit into from
Closed

types: loose cache types #1937

wants to merge 1 commit into from

Conversation

huozhi
Copy link
Member

@huozhi huozhi commented Apr 20, 2022

Makes type of cache looser, so user could use any method without inferring or use type casting

x-ref: #161
x-ref: #1775
x-ref: #1480
Closes: #1936

@huozhi huozhi requested a review from shuding as a code owner April 20, 2022 11:47
@codesandbox-ci
Copy link

codesandbox-ci bot commented Apr 20, 2022

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 3f308e9:

Sandbox Source
SWR-Basic Configuration
SWR-States Configuration
SWR-Infinite Configuration
SWR-SSR Configuration

Copy link
Member

@shuding shuding left a comment

Choose a reason for hiding this comment

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

so user could use any method without inferring or use type casting

This is like making it any, and the user can easily do something wrong. I think we should be more strict on APIs.

@huozhi
Copy link
Member Author

huozhi commented Apr 20, 2022

I think we should be more strict on APIs.

100% agree with the intention, but the cache is coming from context which is not predictable. Another option I can think of is to give a generic parameter in useSWRConfig hook to specifiy the type of cache. But it's kinda like using as for type casting...

@promer94
Copy link
Collaborator

maybe #1938 could be an alternative ?

@huozhi huozhi closed this in #1938 Apr 20, 2022
@huozhi huozhi deleted the loose-cache-types branch April 20, 2022 22:13
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.

None yet

3 participants