4

I don't quite understand what is the purpose of ActionsObservable. There's nothing about it in the documentation but I see it being used here and there in examples.

Why not just use:

import { of } from 'rxjs/observable/of';

or

import { from } from 'rxjs/observable/from';

?

Tomasz Mularczyk
  • 34,501
  • 19
  • 112
  • 166

1 Answers1

4

Once I started writing test I came across a situation where an epic has been calling:

action$.ofType(CREATE_PAYMENT_METHOD))

and because a "regular" Observable doesn't have ofType in prototype chain it was throwing an error when I was stubbing actions:

const action$ = of({
  type: types.CREATE_PAYMENT,
});

const response = await epics.createPayment(action$, store, fetch)
  .pipe(toArray()).toPromise();

action$.ofType is not a function

It worked when I used:

const action$ = ActionsObservable.of({
  type: types.CREATE_PAYMENT,
});
Tomasz Mularczyk
  • 34,501
  • 19
  • 112
  • 166