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

Resolves #1723 - added typings for store.observable method. #1725

Closed
wants to merge 1 commit into from
Closed
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
29 changes: 29 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,27 @@ export interface Unsubscribe {
(): void;
}

/**
* Represents an observer of an observable.
*/
export interface Observer<S> {
next(state: S): void;
}

/**
* A disposable resource returned after subscribing to an observable.
*/
export interface Subscription {
unsubscribe: Unsubscribe;
}

/**
* Represents an observable stream returned by `Store.observable()`.
*/
export interface Observable<S> {
subscribe(observer: Observer<S>): Subscription;
}

/**
* A store is an object that holds the application’s state tree.
* There should only be a single store in a Redux app, as the composition
Expand Down Expand Up @@ -183,6 +204,14 @@ export interface Store<S> {
* @param nextReducer The reducer for the store to use instead.
*/
replaceReducer(nextReducer: Reducer<S>): void;

/**
* Interoperability point for observable/reactive libraries.
* @returns {observable} A minimal observable of state changes.
* For more information, see the observable proposal:
* https://github.com/zenparsing/es-observable
*/
observable(): Observable<S>;
}

/**
Expand Down