blob: 9a4f747900b75b753b97acc5d6e2cd01102785c7 (
about) (
plain)
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
|
import { createTransform } from 'redux-persist';
const GithubTransform = createTransform(
// transform state on its way to being serialized and persisted.
(inboundState, key) => {
inboundState = inboundState || {};
// Keep the first group only to avoid overflowing the storage
if (inboundState.repositories && inboundState.repositories.length > 1) {
inboundState = {
...inboundState,
repositories: [
inboundState.repositories[0]
]
};
}
// Do not persist `processing` flag or `error` information,
// as we want to start fresh on reload in such cases
inboundState = {
...inboundState,
processing: false,
error: null
};
return inboundState;
},
// transform state being rehydrated
(outboundState, key) => {
return { ...outboundState };
},
// define which reducers this transform gets called for.
{
whitelist: ['github']
}
);
export default GithubTransform;
|