Skip to content

Commit

Permalink
(types): flow fixes (#692)
Browse files Browse the repository at this point in the history
  • Loading branch information
rt2zz committed Feb 1, 2018
1 parent 58e14d6 commit de1dbcf
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"eslint": "^4.8.0",
"eslint-plugin-flowtype": "^2.30.4",
"eslint-plugin-import": "^2.2.0",
"flow-bin": "^0.59.0",
"flow-bin": "^0.64.0",
"flow-copy-source": "^1.1.0",
"husky": "^0.13.3",
"lint-staged": "^3.4.0",
Expand Down
11 changes: 6 additions & 5 deletions src/createPersistoid.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ export default function createPersistoid(config: PersistConfig): Persistoid {
const whitelist: ?Array<string> = config.whitelist || null
const transforms = config.transforms || []
const throttle = config.throttle || 0
const storageKey = `${config.keyPrefix !== undefined
? config.keyPrefix
: KEY_PREFIX}${config.key}`
const storageKey = `${
config.keyPrefix !== undefined ? config.keyPrefix : KEY_PREFIX
}${config.key}`
const storage = config.storage
const serialize = config.serialize === false ? x => x : defaultSerialize

// initialize stateful values
let lastState = {}
let stagedState = {}
let keysToProcess = []
let timeIterator: ?number = null
let timeIterator: ?IntervalID = null
let writePromise = null

const update = (state: Object) => {
Expand Down Expand Up @@ -79,7 +79,8 @@ export default function createPersistoid(config: PersistConfig): Persistoid {
}

function passWhitelistBlacklist(key) {
if (whitelist && whitelist.indexOf(key) === -1 && key !== '_persist') return false
if (whitelist && whitelist.indexOf(key) === -1 && key !== '_persist')
return false
if (blacklist && blacklist.indexOf(key) !== -1) return false
return true
}
Expand Down
6 changes: 5 additions & 1 deletion src/persistStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ export default function persistStore(
})
}
let boostrappedCb = cb || false
let persistor = createStore(persistorReducer, undefined, options.enhancer)
let persistor: Persistor = createStore(
persistorReducer,
undefined,
options.enhancer
)

persistor.purge = () => {
let results = []
Expand Down
7 changes: 5 additions & 2 deletions src/types.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// @flow
import { REHYDRATE, REGISTER } from './constants'

export type PersistState = {
version: number,
Expand Down Expand Up @@ -48,7 +49,7 @@ export type Transform = {
export type RehydrateErrorType = any

export type RehydrateAction = {
type: 'redux-persist/REHYDRATE',
type: typeof REHYDRATE,
key: string,
payload: ?Object,
err: ?RehydrateErrorType,
Expand All @@ -60,7 +61,7 @@ export type Persistoid = {
}

type RegisterAction = {
type: 'redux-persist/REGISTER',
type: typeof REGISTER,
key: string,
}

Expand All @@ -74,6 +75,8 @@ type PersistorState = {
type PersistorSubscribeCallback = () => any

export type Persistor = {
pause: () => void,
persist: () => void,
purge: () => Promise<any>,
flush: () => Promise<any>,
+dispatch: PersistorAction => PersistorAction,
Expand Down

0 comments on commit de1dbcf

Please sign in to comment.