Skip to content

Commit

Permalink
Declare TypeScript types
Browse files Browse the repository at this point in the history
Fixes #5
  • Loading branch information
ankon committed Sep 3, 2019
1 parent 02d6e3e commit 21faec8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
18 changes: 18 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// See https://github.com/xuoe/redux-observers/issues/5
import { Dispatch, Store, Unsubscribe } from 'redux';

export function shallowEquals(a: any, b: any): boolean;

interface Options {
skipInitialCall?: boolean;
equals?: typeof shallowEquals;
}

type Observer<S = any, MS = any> = unknown;
type Mapper<S = any, MS = any> = (state: S) => MS;
type Dispatcher<MS> = (dispatch: Dispatch<MS>, currentState: MS, previousState: MS) => unknown;

export function observer<S, MS>(mapper: Mapper<S, MS>, dispatcher: Dispatcher<MS>, options?: Options): Observer<S, MS>;
export function observer<S>(dispatcher: Dispatcher<S>, options?: Options): Observer<S, S>;

export function observe<S>(store: Store<S>, observers: Observer[], options?: Options): Unsubscribe;
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"license": "MIT",
"main": "lib/index.js",
"jsnext:main": "src/index.js",
"types": "index.d.ts",
"scripts": {
"build": "babel src --out-dir lib",
"clean": "rimraf lib coverage",
Expand Down Expand Up @@ -37,5 +38,8 @@
"keywords": [
"redux",
"observer"
]
],
"dependencies": {
"@types/redux": "^3.6.0"
}
}

0 comments on commit 21faec8

Please sign in to comment.