-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.mjs
More file actions
69 lines (63 loc) · 1.98 KB
/
Copy pathtypes.mjs
File metadata and controls
69 lines (63 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/**
* The cache key.
* @kind typedef
* @name CacheKey
* @type {string|Array<string|number>}
*/
/**
* Loads data into the cache.
* @kind typedef
* @name DataCacheLoad
* @type {Function}
* @param {CacheKey} key A cache key.
* @param {Function} asyncFn A function that returns a Promise.
*/
/**
* @kind typedef
* @name SubscriptionSubscribe
* @type {Function}
* @param {Function} callback A function to call whenever an event occurs.
* @returns {Function} Unsubscribe.
*/
/**
* Returns cached entry if found, otherwise calls asyncFn and loads data into the cache.
* @kind typedef
* @name DataCachePreload
* @type {Function}
* @param {CacheKey} key A cache key.
* @param {Function} asyncFn A function that returns a Promise.
*/
/**
* Loads data into this cache reference.
* @kind typedef
* @name UseDataLoaderLoad
* @type {Function}
* @param {Function} asyncFn A function that returns a Promise.
*/
/**
* A dataCache object.
* @kind typedef
* @name DataCache
* @type {object}
* @prop {Map} cache The cache.
* @prop {Function} get Internal API.
* @prop {Function} set Internal API.
* @prop {CreateSubscriptionAPI} subscription Internal API.
* @prop {DataCachePreload} preload Preload asynchronous data.
* @prop {DataCacheLoad} load Load asynchronous data.
* @prop {string|Function} find Find references by key, takes a string or predicate function.
* @prop {SubscriptionSubscribe} onChange Called whenever cache is updated. First argument is key of updated reference.
* @prop {Function} reset Resets the cache.
*/
/**
* A cache reference object.
* @ignore
* @kind typedef
* @name CacheReference
* @type {object}
* @prop {boolean} loadOnMount If this reference has mounted once before, we trigger stale-while-revalidate, unless reloadOnMount = false.
* @prop {CacheKey} key The cache key.
* @prop {Function} asyncFn User provided async function.
* @prop {Function} load Calls the async function and loads data.
* @prop {Function} onUpdate Subscribe to data events.
*/