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

Observable cache, and fix for double use effect calls. #1

Merged
merged 11 commits into from
Dec 28, 2022

Conversation

jcblw
Copy link
Owner

@jcblw jcblw commented Dec 20, 2022

Description

This PR adds many improvements around the cache and fixes double fetches in React 18. Some of the improvements are.

  • Changes cache structure to introduce Observables to replace POJOs. This allows for observing individual query cache.
  • useQuery now fetches on initialization and avoids fetching in the use effect.
  • useQuery now uses the cache directly using the useSyncExternalStore.
  • Adds a cache policy and a way to respond with cache if it's available.
  • Add a way to invalidate the cache

Testing

  • Includes test.
  • Manually tested.

Additional notes

This is a breaking change, so I think it might be best to introduce some more breaks before merging this into the release.

@jcblw jcblw changed the title Feature/observable cache Observable cache, and fix for double use effect calls. Dec 21, 2022
@jcblw jcblw merged commit f238c1f into main Dec 28, 2022
jcblw added a commit that referenced this pull request Jan 23, 2023
* turn each query into an observable

* hook up observable and to react client

* trigger workflow

* get tests working, and add awaited type

* fix some of the types, with the data

* add in cache policy

* move types to root of client package

* fix some test and properly resolve query promise

* add in fetch first policy to the refetch

* add in test for invalidation, and fix the issue with invalidation and lifecycle subscriptions

* rename master to main
jcblw added a commit that referenced this pull request Jan 23, 2023
* turn each query into an observable

* hook up observable and to react client

* trigger workflow

* get tests working, and add awaited type

* fix some of the types, with the data

* add in cache policy

* move types to root of client package

* fix some test and properly resolve query promise

* add in fetch first policy to the refetch

* add in test for invalidation, and fix the issue with invalidation and lifecycle subscriptions

* rename master to main
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.

1 participant