Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Update Type Definitions and API Docs to Make Sure They Match #5

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
24 changes: 16 additions & 8 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,13 @@ createMigrate(
### `type Persistor`
```js
{
pause: () => void,
persist: () => void,
purge: () => Promise<void>,
flush: () => Promise<void>,
dispatch: (action: PersistorAction) => PersistorAction,
getState: () => PersistorState,
subscribe: (callback: PersistorSubscribeCallback) => any
}
```

Expand All @@ -51,29 +56,32 @@ The Persistor is a redux store unto itself, plus
### `type PersistConfig`
```js
{
key: string, // the key for the persist
storage: Object, // the storage adapter, following the AsyncStorage api
version?: number, // the state version as an integer (defaults to -1)
storage: Object, // the storage adapter, following the AsyncStorage api
key: string, // the key for the persist
keyPrefix?: string, // will be prefixed to the storage key
blacklist?: Array<string>, // do not persist these keys
whitelist?: Array<string>, // only persist these keys
migrate?: (Object, number) => Promise<Object>,
transforms?: Array<Transform>,
throttle?: number, // ms to throttle state writes
keyPrefix?: string, // will be prefixed to the storage key
debug?: boolean, // true -> verbose logs
migrate?: (Object, number) => Promise<Object>,
stateReconciler?: false | StateReconciler, // false -> do not automatically reconcile state
getStoredState?: (PersistConfig<S, RS, HSS, ESS>) => Promise<PersistedState>
debug?: boolean, // true -> verbose logs
serialize?: boolean, // false -> do not call JSON.parse & stringify when setting & getting from storage
deserialize?: boolean | ((any) => any)
timeout?: number;
writeFailHandler?: Function, // will be called if the storage engine fails during setItem()
}
```

Persisting state involves calling setItem() on the storage engine. By default, this will fail silently if the storage/quota is exhausted.
Provide a writeFailHandler(error) function to be notified if this occurs.
Persisting state involves calling `setItem()` on the storage engine. By default, this will fail silently if the storage/quota is exhausted.
Provide a `writeFailHandler(error)` function to be notified if this occurs.

### `type MigrationManifest`
```js
{
[number]: (State) => State
[string]: (State) => State
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed this to a string type to match what's in the types.ts file, but I'm wondering, is number correct here? If you look at the migrations.md example, the keys are numbers. So, is the types.ts file wrong or is the api.md and migrations.md files wrong?

}
```
Where the keys are state version numbers and the values are migration functions to modify state.
Expand Down
3 changes: 2 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

151 changes: 0 additions & 151 deletions types/types.d.ts

This file was deleted.