|
| 1 | +/// <reference types="symbol-observable" /> |
| 2 | + |
1 | 3 | /**
|
2 | 4 | * An *action* is a plain object that represents an intention to change the
|
3 | 5 | * state. Actions are the only way to get data into the store. Any data,
|
@@ -129,6 +131,32 @@ export interface Unsubscribe {
|
129 | 131 | (): void
|
130 | 132 | }
|
131 | 133 |
|
| 134 | +/** |
| 135 | + * A minimal observable of state changes. |
| 136 | + * For more information, see the observable proposal: |
| 137 | + * https://github.com/tc39/proposal-observable |
| 138 | + */ |
| 139 | +export type Observable<T> = { |
| 140 | + /** |
| 141 | + * The minimal observable subscription method. |
| 142 | + * @param {Object} observer Any object that can be used as an observer. |
| 143 | + * The observer object should have a `next` method. |
| 144 | + * @returns {subscription} An object with an `unsubscribe` method that can |
| 145 | + * be used to unsubscribe the observable from the store, and prevent further |
| 146 | + * emission of values from the observable. |
| 147 | + */ |
| 148 | + subscribe: (observer: Observer<T>) => { unsubscribe: Unsubscribe } |
| 149 | + [Symbol.observable](): Observable<T> |
| 150 | +} |
| 151 | + |
| 152 | +/** |
| 153 | + * An Observer is used to receive data from an Observable, and is supplied as |
| 154 | + * an argument to subscribe. |
| 155 | + */ |
| 156 | +export type Observer<T> = { |
| 157 | + next?(value: T): void |
| 158 | +} |
| 159 | + |
132 | 160 | /**
|
133 | 161 | * A store is an object that holds the application's state tree.
|
134 | 162 | * There should only be a single store in a Redux app, as the composition
|
@@ -209,6 +237,14 @@ export interface Store<S = any, A extends Action = AnyAction> {
|
209 | 237 | * @param nextReducer The reducer for the store to use instead.
|
210 | 238 | */
|
211 | 239 | replaceReducer(nextReducer: Reducer<S, A>): void
|
| 240 | + |
| 241 | + /** |
| 242 | + * Interoperability point for observable/reactive libraries. |
| 243 | + * @returns {observable} A minimal observable of state changes. |
| 244 | + * For more information, see the observable proposal: |
| 245 | + * https://github.com/tc39/proposal-observable |
| 246 | + */ |
| 247 | + [Symbol.observable](): Observable<S> |
212 | 248 | }
|
213 | 249 |
|
214 | 250 | export type DeepPartial<T> = {
|
|
0 commit comments