Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
390
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. import * as actionTypes from '../actions/type';
  2. import {Observable} from 'rxjs';
  3.  
  4. const fakeApi = () => Observable.of({
  5. userId: 1,
  6. name: "chris",
  7. position: "Front-end",
  8. email: "chris.ho@innovatube.com"
  9. }).delay(2000);
  10.  
  11. export default action$ => action$.ofType(actionTypes.FETCH_USER)
  12. .mergeMap(() => fakeApi()
  13. .map(response => ({
  14. type: actionTypes.FETCH_USER_SUCCESS,
  15. payload: response})
  16. ).takeUntil(action$.ofType(actionTypes.CANCEL_FETCHING_USER))
  17. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement