File tree Expand file tree Collapse file tree 1 file changed +14
-13
lines changed Expand file tree Collapse file tree 1 file changed +14
-13
lines changed Original file line number Diff line number Diff line change 1212// of values or Errors.
1313type BatchLoadFn < K , V > = ( keys : Array < K > ) => Promise < Array < V | Error >> ;
1414
15+ // Optionally turn off batching or caching or provide a cache key function or a
16+ // custom cache instance.
17+ type Options < K , V > = {
18+ batch ?: boolean ;
19+ cache ? : boolean ;
20+ cacheKeyFn ?: ( key : any ) => any ;
21+ cacheMap ?: CacheMap < K , Promise < V >> ;
22+ } ;
23+
24+ // If a custom cache is provided, it must be of this type (a subset of ES6 Map).
1525type CacheMap < K , V > = {
1626 get ( key : K ) : V | void ;
1727 set ( key : K , value : V ) : any ;
1828 delete ( key : K ) : any ;
1929 clear ( ) : any ;
2030} ;
2131
22- // Optionally turn off batching or caching or provide a cache key function or a
23- // custom cache instance.
24- type Options < K , V > = {
25- batch ?: boolean ,
26- cache ?: boolean ,
27- cacheMap ?: CacheMap < K , Promise< V >> ,
28- cacheKeyFn ?: ( key : any ) => any
29- } ;
30-
3132/**
3233 * A `DataLoader` creates a public API for loading data from a particular
3334 * data back-end with unique keys such as the `id` column of a SQL table or
@@ -285,7 +286,7 @@ function failedDispatch<K, V>(
285286
286287// Private
287288type LoaderQueue < K , V > = Array < {
288- key : K ,
289- resolve : ( value : V ) => void ,
290- reject : ( error : Error ) => void
291- } >
289+ key : K ;
290+ resolve : ( value : V ) = > void ;
291+ reject : ( error : Error ) = > void ;
292+ } > ;
You can’t perform that action at this time.
0 commit comments