Permalink
Browse files

feat(redux): update to redux v4 (#501)

BREAKING CHANGE: redux-observable now requires redux v4. The new version of redux is mostly the same, however it required us to change the `createEpicMiddleware` API. See https://redux-observable.js.org/MIGRATION.html
  • Loading branch information...
evertbouw authored and jayphelps committed May 31, 2018
1 parent 98727a8 commit 43c2033737b8905b0954e32a7cfd69534e5bded7
Showing with 19 additions and 19 deletions.
  1. +2 −2 package.json
  2. +8 −13 test/createEpicMiddleware-spec.js
  3. +1 −0 test/initAction.d.ts
  4. +3 −0 test/initAction.js
  5. +5 −4 test/typings.ts
@@ -64,7 +64,7 @@
},
"homepage": "https://github.com/redux-observable/redux-observable#README.md",
"peerDependencies": {
"redux": ">=3 <4",
"redux": ">=4 <5",
"rxjs": ">=6.0.0-beta.0 <7"
},
"devDependencies": {
@@ -95,7 +95,7 @@
"gulp-babel": "^6.1.2",
"json-server": "^0.10.0",
"mocha": "^3.5.3",
"redux": "^3.5.2",
"redux": "^4.0.0",
"rimraf": "^2.5.4",
"rxjs": "^6.0.0",
"sinon": "^4.5.0",
@@ -7,6 +7,7 @@ import { createEpicMiddleware, combineEpics, ActionsObservable, StateObservable,
import { resetDeprecationsSeen } from '../lib/cjs/utils/console';
import { of, empty, merge } from 'rxjs';
import { mapTo, filter, map, mergeMap, startWith, ignoreElements, distinctUntilChanged } from 'rxjs/operators';
import { initAction } from './initAction';
describe('createEpicMiddleware', () => {
let spySandbox;
@@ -103,9 +104,7 @@ describe('createEpicMiddleware', () => {
store.dispatch({ type: 'PING' });
expect(store.getState()).to.equal(2);
expect(actions).to.deep.equal([{
type: '@@redux/INIT'
}, {
expect(actions).to.deep.equal([initAction, {
type: 'PING'
}, {
type: 'PONG',
@@ -167,9 +166,7 @@ describe('createEpicMiddleware', () => {
store.dispatch({ type: 'FIRST' });
expect(store.getState().value).to.equal(8);
expect(actions).to.deep.equal([{
type: '@@redux/INIT'
}, {
expect(actions).to.deep.equal([initAction, {
type: 'FIRST'
}, {
type: 'STATE',
@@ -209,9 +206,7 @@ describe('createEpicMiddleware', () => {
expect(console.warn.callCount).to.equal(1);
expect(console.warn.getCall(0).args[0]).to.equal('redux-observable | WARNING: You accessed state$.value inside one of your Epics, before your reducers have run for the first time, so there is no state yet. You\'ll need to wait until after the first action (@@redux/INIT) is dispatched or by using state$ as an Observable.');
expect(store.getState()).to.deep.equal([{
type: '@@redux/INIT'
}, {
expect(store.getState()).to.deep.equal([initAction, {
type: 'PONG',
state: undefined
}, {
@@ -268,7 +263,7 @@ describe('createEpicMiddleware', () => {
store.dispatch({ type: 'FIRE_2' });
expect(store.getState()).to.deep.equal([
{ type: '@@redux/INIT' },
initAction,
{ type: 'FIRE_1' },
{ type: 'ACTION_1' },
{ type: 'FIRE_2' },
@@ -291,7 +286,7 @@ describe('createEpicMiddleware', () => {
middleware.run(rootEpic);
expect(store.getState()).to.deep.equal([
{ type: '@@redux/INIT' },
initAction,
{ type: 'ACTION_1' },
{ type: 'ACTION_2' }
]);
@@ -321,7 +316,7 @@ describe('createEpicMiddleware', () => {
middleware.run(rootEpic);
expect(store.getState()).to.deep.equal([
{ type: '@@redux/INIT' },
initAction,
{ type: 'ACTION_1' },
{ type: 'ACTION_2' },
{ type: 'ACTION_3' },
@@ -394,7 +389,7 @@ describe('createEpicMiddleware', () => {
middleware.run(epic);
expect(store.getState()).to.deep.equal([
{ type: '@@redux/INIT' },
initAction,
{ type: 3 }
]);
});
@@ -0,0 +1 @@
export const initAction: { type: string };
@@ -0,0 +1,3 @@
import { __DO_NOT_USE__ActionTypes as actionTypes } from 'redux';
export const initAction = { type: actionTypes.INIT };
@@ -6,6 +6,7 @@ import { map, mapTo, mergeMap } from 'rxjs/operators';
import { createEpicMiddleware, Epic, combineEpics,
EpicMiddleware, ActionsObservable, StateObservable, ofType } from '../';
import { initAction } from './initAction';
interface State {
foo: string
@@ -170,27 +171,27 @@ store.dispatch({ type: 'EIGHTH', payload: 'eighth-payload' });
store.dispatch({ type: 'NINTH', payload: 'ninth-payload' });
expect(store.getState()).to.deep.equal([
{ "type": "@@redux/INIT" },
initAction,
{ "type": "fourth" },
{ "type": "fourth" },
{ "type": "FIRST" },
{ "type": "first",
"payload": [
{ "type": "@@redux/INIT" },
initAction,
{ "type": "fourth" },
{ "type": "fourth" },
{ "type": "FIRST" }
]
},
{ "type": "first",
"payload": [
{ "type": "@@redux/INIT" },
initAction,
{ "type": "fourth" },
{ "type": "fourth" },
{ "type": "FIRST" },
{ "type": "first",
"payload": [
{ "type": "@@redux/INIT" },
initAction,
{ "type": "fourth" },
{ "type": "fourth" },
{ "type": "FIRST" }

0 comments on commit 43c2033

Please sign in to comment.