Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix(typings): Add dependencies to middleware options. (#207)
  • Loading branch information
sebald authored and jayphelps committed Mar 3, 2017
1 parent 331440c commit fb911a8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion index.d.ts
Expand Up @@ -9,7 +9,7 @@ export declare class ActionsObservable<T> extends Observable<T> {
* because we would need non-final position spread params e.g.
* `static of<T>(...items: T, scheduler?: Scheduler): ActionsObservable<T>`
* which isn't possible in either JavaScript or TypeScript. So instead, we
* provide safe typing for up to 6 items, following by a scheduler.
* provide safe typing for up to 6 items, following by a scheduler.
*/
static of<T>(item1: T, scheduler?: Scheduler): ActionsObservable<T>;
static of<T>(item1: T, item2: T, scheduler?: Scheduler): ActionsObservable<T>;
Expand Down Expand Up @@ -42,6 +42,7 @@ interface Adapter {

interface Options {
adapter?: Adapter;
dependencies: { [key:string]: any }
}

export declare function createEpicMiddleware<T, S>(rootEpic: Epic<T, S>, options?: Options): EpicMiddleware<T, S>;
Expand Down
5 changes: 5 additions & 0 deletions test/typings.ts
@@ -1,6 +1,7 @@
import { expect } from 'chai';
import { createStore, applyMiddleware, MiddlewareAPI } from 'redux';
import { Observable } from 'rxjs/Observable';
import { ajax } from 'rxjs/observable/dom/ajax';
import { asap } from 'rxjs/scheduler/asap';
import 'rxjs/add/observable/of';
import 'rxjs/add/operator/mapTo';
Expand Down Expand Up @@ -78,6 +79,10 @@ const customEpic2 = (action$, store, some) =>
payload
}));

const customEpicMiddleware: EpicMiddleware<FluxStandardAction, any> = createEpicMiddleware<FluxStandardAction, any>(rootEpic1, {
dependencies: { getJSON: ajax.getJSON }
});

const combinedCustomEpics = combineEpics<CustomEpic<FluxStandardAction, any, any>>(customEpic, customEpic2);

const reducer = (state = [], action) => state.concat(action);
Expand Down

0 comments on commit fb911a8

Please sign in to comment.