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

enhance: useCache() and useStatefulResource() respect invalidIfStale #307

Merged
merged 3 commits into from Mar 29, 2020

Conversation

ntucker
Copy link
Collaborator

@ntucker ntucker commented Mar 29, 2020

BREAKING CHANGE: When invalidIfStale is true, useCache() and
useStatefulResource() will no longer return entities, even if they
are in the cache

Motivation

invalidIfStale was added, and its behavior affected suspense, which is the primary mechanism to use data. However, as other use cases expanded it became clear that equivalent behavior should be reflected in the other hooks. This is especially important when not using suspense at all - for instance when useStatefulResource().

Solution

This only changes behavior when invalidIfStale is true.

In this case, we should consider the same case where useResource() would suspend and return 'empty' results. This is key for replicating the same behaviors and patterns with both useCache() and useStatefulResource().

@github-actions
Copy link
Contributor

github-actions bot commented Mar 29, 2020

Size Change: +322 B (1%)

Total Size: 30.3 kB

Filename Size Change
packages/legacy/dist/index.cjs.js 433 B +9 B (2%)
packages/rest-hooks/dist/index.cjs.js 16.7 kB +227 B (1%)
packages/rest-hooks/dist/index.umd.min.js 7.08 kB +86 B (1%)
ℹ️ View Unchanged
Filename Size Change
packages/legacy/dist/index.umd.min.js 376 B 0 B
packages/normalizr/dist/normalizr.es.min.js 2.17 kB 0 B
packages/test/dist/index.cjs.js 1.84 kB 0 B
packages/use-enhanced-reducer/dist/index.cjs.js 1.08 kB 0 B
packages/use-enhanced-reducer/dist/index.umd.min.js 593 B 0 B

compressed-size-action

BREAKING CHANGE: When invalidIfStale is true, useCache() and
useStatefulResource() will no longer return data, even if it
is in the cache
@ntucker ntucker merged commit 58f2c40 into master Mar 29, 2020
@ntucker ntucker deleted the expired-data-invalid branch March 29, 2020 07:24
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

1 participant