@khanacademy/wonder-blocks-data 14.1.5 → 14.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/hooks/use-cached-effect.d.ts +19 -1
- package/dist/util/types.d.ts +25 -6
- package/package.json +15 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @khanacademy/wonder-blocks-data
|
|
2
2
|
|
|
3
|
+
## 14.1.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 6d5c485: Include provenance information when publishing to npmjs
|
|
8
|
+
- Updated dependencies [6d5c485]
|
|
9
|
+
- @khanacademy/wonder-blocks-core@12.4.1
|
|
10
|
+
|
|
11
|
+
## 14.1.6
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- 642b5d7: Update docs to provide clearer details on fetch policy behaviors
|
|
16
|
+
|
|
3
17
|
## 14.1.5
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -5,9 +5,27 @@ type CachedEffectOptions<TData extends ValidCacheData> = {
|
|
|
5
5
|
* The policy to use when determining how to retrieve the request data from
|
|
6
6
|
* cache and network.
|
|
7
7
|
*
|
|
8
|
+
* Inflight requests are shared so that multiple requests for the same
|
|
9
|
+
* resource do not cause multiple fetches while one fetch is already in
|
|
10
|
+
* progress.
|
|
11
|
+
*
|
|
12
|
+
* Network requests update the cache on return, regardless of which policy
|
|
13
|
+
* initiated the request.
|
|
14
|
+
*
|
|
15
|
+
* For fetch policies that use the cache, if the cache does not yet have
|
|
16
|
+
* the data, then a `no-data` status is returned.
|
|
17
|
+
*
|
|
18
|
+
* The `FetchPolicy.NetworkOnly` and `FetchPolicy.CacheAndNetwork` only
|
|
19
|
+
* fetch the data once and then reuse that result, unless a re-fetch is
|
|
20
|
+
* explicitly triggered via the fetch function in the returned tuple.
|
|
21
|
+
*
|
|
22
|
+
* For `FetchPolicy.NetworkOnly`, the cache is ignored (but the cache
|
|
23
|
+
* is still updated with the fetched value). Until a value is available,
|
|
24
|
+
* a `loading` status is returned for this policy.
|
|
25
|
+
*
|
|
8
26
|
* Defaults to `FetchPolicy.CacheBeforeNetwork`.
|
|
9
27
|
*/
|
|
10
|
-
fetchPolicy?:
|
|
28
|
+
fetchPolicy?: FetchPolicy;
|
|
11
29
|
/**
|
|
12
30
|
* When `true`, the effect will not be executed; otherwise, the effect will
|
|
13
31
|
* be executed.
|
package/dist/util/types.d.ts
CHANGED
|
@@ -1,24 +1,43 @@
|
|
|
1
1
|
import type { Metadata } from "@khanacademy/wonder-stuff-core";
|
|
2
2
|
/**
|
|
3
3
|
* Defines the various fetch policies that can be applied to requests.
|
|
4
|
+
*
|
|
5
|
+
* If a policy fetches from the server, then the cache will be updated with
|
|
6
|
+
* the result of that fetch, once it completes. Inflight fetches are shared
|
|
7
|
+
* so that multiple requests for the same resource do not cause multiple
|
|
8
|
+
* fetches while one fetch is already in progress.
|
|
9
|
+
*
|
|
10
|
+
* It is up to the implementation to decide how to handle cache misses, but
|
|
11
|
+
* most cases likely return a `no-data` or, in the case of a network-only
|
|
12
|
+
* policy, `loading` result, depending on the policy.
|
|
4
13
|
*/
|
|
5
14
|
export declare enum FetchPolicy {
|
|
6
15
|
/**
|
|
7
|
-
* If the data is in the cache,
|
|
8
|
-
* server.
|
|
16
|
+
* If the data is in the cache, use that data and do not fetch.
|
|
17
|
+
* Otherwise, provide `no-data` while data is fetched from the server.
|
|
18
|
+
*
|
|
19
|
+
* This is usually the policy you want. It means the value is retrieved
|
|
20
|
+
* once and then reused from cache thereafter.
|
|
9
21
|
*/
|
|
10
22
|
CacheBeforeNetwork = "CacheBeforeNetwork",
|
|
11
23
|
/**
|
|
12
|
-
* If the data is in the cache,
|
|
13
|
-
*
|
|
24
|
+
* If the data is in the cache, use that data, but also fetch an update
|
|
25
|
+
* from the server if one was not already fetched.
|
|
26
|
+
* Otherwise, provide `no-data` while data is fetched from the server.
|
|
27
|
+
*
|
|
28
|
+
* If there is no cached data, this behaves like `NetworkOnly` while
|
|
29
|
+
* data is being fetched. If there is cached data, this behaves like
|
|
30
|
+
* `CacheOnly` while data is being fetched, and then updates the cache
|
|
31
|
+
* when the fetch completes, before acting like `NetworkOnly` thereafter.
|
|
14
32
|
*/
|
|
15
33
|
CacheAndNetwork = "CacheAndNetwork",
|
|
16
34
|
/**
|
|
17
|
-
* If the data is in the cache,
|
|
35
|
+
* If the data is in the cache, use that; otherwise, provide `no-data`.
|
|
18
36
|
*/
|
|
19
37
|
CacheOnly = "CacheOnly",
|
|
20
38
|
/**
|
|
21
|
-
* Ignore any existing cached result;
|
|
39
|
+
* Ignore any existing cached result; fetch data from the server, if it
|
|
40
|
+
* wasn't already fetched. While there is no data, provide `loading`.
|
|
22
41
|
*/
|
|
23
42
|
NetworkOnly = "NetworkOnly"
|
|
24
43
|
}
|
package/package.json
CHANGED
|
@@ -1,16 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@khanacademy/wonder-blocks-data",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
3
|
+
"description": "",
|
|
4
|
+
"author": "Khan Academy",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"version": "14.1.7",
|
|
5
7
|
"publishConfig": {
|
|
6
8
|
"access": "public"
|
|
7
9
|
},
|
|
8
|
-
"
|
|
10
|
+
"design": "v1",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://github.com/Khan/wonder-blocks.git",
|
|
14
|
+
"directory": "packages/wonder-blocks-data"
|
|
15
|
+
},
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/Khan/wonder-blocks/issues"
|
|
18
|
+
},
|
|
9
19
|
"main": "dist/index.js",
|
|
10
20
|
"module": "dist/es/index.js",
|
|
11
21
|
"types": "dist/index.d.ts",
|
|
12
22
|
"dependencies": {
|
|
13
|
-
"@khanacademy/wonder-blocks-core": "12.4.
|
|
23
|
+
"@khanacademy/wonder-blocks-core": "12.4.1"
|
|
14
24
|
},
|
|
15
25
|
"peerDependencies": {
|
|
16
26
|
"@khanacademy/wonder-stuff-core": "^1.5.4",
|
|
@@ -19,10 +29,8 @@
|
|
|
19
29
|
"devDependencies": {
|
|
20
30
|
"@khanacademy/wonder-stuff-testing": "^3.0.5",
|
|
21
31
|
"@khanacademy/wb-dev-build-settings": "3.2.0",
|
|
22
|
-
"@khanacademy/wonder-blocks-testing-core": "
|
|
32
|
+
"@khanacademy/wonder-blocks-testing-core": "4.0.2"
|
|
23
33
|
},
|
|
24
|
-
"author": "",
|
|
25
|
-
"license": "MIT",
|
|
26
34
|
"scripts": {
|
|
27
35
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
28
36
|
}
|