File tree Expand file tree Collapse file tree 3 files changed +21
-17
lines changed Expand file tree Collapse file tree 3 files changed +21
-17
lines changed Original file line number Diff line number Diff line change 1
1
/* @flow */
2
2
// Add `strict` once Dispatch type is added
3
3
4
- import type { JSONAPIResource , JSONAPIResourceIdentifier } from 'json-api' ;
4
+ import type { JSONAPIResource } from 'json-api' ;
5
5
import React , { type Node , PureComponent } from 'react' ;
6
6
import { connect } from 'react-redux' ;
7
7
import { readEndpoint } from 'redux-json-api' ;
8
+ import type { Links , CachedResponse } from './types' ;
8
9
import DataSet from './DataSet' ;
9
10
import QueryCache from './QueryCache' ;
10
11
11
- type Link = { |
12
- load : ( ) => void ,
13
- | } ;
14
-
15
- type Links = { [ string ] : Link } ;
16
-
17
12
type Refetch = ( ) => void ;
18
13
19
- export type StoredResponse = { |
20
- links : Links ,
21
- resourceIds : Array < JSONAPIResourceIdentifier > ,
22
- | } ;
23
-
24
14
type RenderProp = ( {
25
15
error ?: Error ,
26
16
loading : boolean ,
@@ -39,7 +29,7 @@ type Props = {|
39
29
type State = { |
40
30
error ? : Error ,
41
31
loading : boolean ,
42
- ...StoredResponse ,
32
+ ...CachedResponse ,
43
33
| } ;
44
34
45
35
export class Query extends PureComponent < Props , State > {
@@ -58,7 +48,7 @@ export class Query extends PureComponent<Props, State> {
58
48
this . loadEndpoint ( this . props . endpoint ) ;
59
49
}
60
50
61
- setResponse = ( { resourceIds, links } : StoredResponse ) => {
51
+ setResponse = ( { resourceIds, links } : CachedResponse ) => {
62
52
this . setState ( {
63
53
resourceIds,
64
54
links,
Original file line number Diff line number Diff line change 1
1
/* @flow strict-local */
2
2
3
- import type { StoredResponse } from './Query ' ;
3
+ import type { CachedResponse } from './types ' ;
4
4
5
5
export default class QueryCache {
6
- static cachedEndpoints : Map < string , StoredResponse > = new Map ( ) ;
6
+ static cachedEndpoints : Map < string , CachedResponse > = new Map ( ) ;
7
7
8
- static cacheEndpoint ( endpoint : string , response : StoredResponse ) {
8
+ static cacheEndpoint ( endpoint : string , response : CachedResponse ) {
9
9
QueryCache . cachedEndpoints . set ( endpoint , response ) ;
10
10
}
11
11
Original file line number Diff line number Diff line change
1
+ /* @flow strict */
2
+
3
+ import type { JSONAPIResourceIdentifier } from 'json-api' ;
4
+
5
+ type Link = { |
6
+ load : ( ) => void ,
7
+ | } ;
8
+
9
+ export type Links = { [ string ] : Link } ;
10
+
11
+ export type CachedResponse = { |
12
+ links : Links ,
13
+ resourceIds : Array < JSONAPIResourceIdentifier > ,
14
+ | } ;
You can’t perform that action at this time.
0 commit comments