5

I am using the latest version of redux-observable and Rxjs i.e

// My version
"redux-observable": "^1.0.0",
"rxjs": "^6.3.2"

The store - middleware, setup looks like this:

// Setting up middlewares
import { pingEpic } from './epics';
import pingReducer from './reducers/pingReducer';

import { combineReducers, createStore, applyMiddleware } from 'redux';
import { combineEpics, createEpicMiddleware } from 'redux-observable';

const rootReducer = combineReducers(pingReducer);
const rootEpic = combineEpics(pingEpic);

const epicMiddleware = createEpicMiddleware();

const store = createStore(rootReducer,
    applyMiddleware(epicMiddleware)
);

epicMiddleware.run(rootEpic);
export default store;

And my epic looks like this

// pingEpic.js
import { mapTo } from 'rxjs/operator/mapTo';
import { ofType } from 'redux-observable';
export const pingEpic = action$ => action$.pipe(
    ofType('PING'),
    mapTo({ type: 'PONG' })
);

So when I executed the program for the first time I got the following error:

enter image description here

I googled it and found a solution here which says to install rxjs-compat@6 (however it doesn't makes any sense) I installed that too! And then I ran into the following error:

enter image description here.

I don't know what/where am I doing wrong? Any help would be much appreciated!

Thanks

Siddhartha Chowdhury
  • 2,724
  • 1
  • 28
  • 46
  • Maybe Your store is somehow configured incorrectly. See how it's done here https://github.com/benawad/pingpong/blob/master/src/store.js – Michal Cholewiński Sep 20 '18 at 10:19
  • @Michal Cholewiński, this project uses the older versions. My store is same store you have pointed out but with the latest changes from 'redux-observable'. "Maybe Your store is somehow configured incorrectly" - Yes of course! My question is how to fix it! – Siddhartha Chowdhury Sep 20 '18 at 11:16

1 Answers1

2

It should be

import { mapTo } from 'rxjs/operators';

instead of

import { mapTo } from 'rxjs/operator/mapTo';

source: https://github.com/ReactiveX/rxjs/blob/master/doc/pipeable-operators.md#usage

Anas
  • 5,622
  • 5
  • 39
  • 71