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

Declare TypeScript types #6

Merged
merged 1 commit into from
Nov 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
}
}