Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request for articles/epics.md #553

Open
westandy-dcp opened this issue Feb 14, 2019 · 2 comments
Open

Request for articles/epics.md #553

westandy-dcp opened this issue Feb 14, 2019 · 2 comments

Comments

@westandy-dcp
Copy link

This is a...

  • feature request

I would like the Epics.md updated to reflect some modern approaches to the login epic. The following example is how we implemented an epic. The main part that bothered me with your current example is the embedded http.post(...).pipe(...) because it reminds me too much of the old callback hell.

For what it is worth, I hope this helps some folks develop cleaner code.

  login = (action$: ActionsObservable) =>
     action$.pipe(
       ofType(SessionActions.LOGIN_USER),
       map(() => getSomePayload()),
       map((payload: SomeStruct) => formatPayload(payload)),
       mergeMap((payload: SomeOtherStruct) => this.http.post(...)),
       map(response:any) => Actions.createAnAction(response)),
       catchError(this.handleError)
    )
@takahser
Copy link

takahser commented Sep 9, 2019

Also, there seems to be a problem with the current version of ActionsObservable.
I keep getting this error:

Generic type 'ActionsObservable' requires 1 type argument(s).ts(2314)

I'm using "redux-observable": "^1.1.0"

@takahser
Copy link

takahser commented Sep 12, 2019

I was able to resolve this issue by replacing the redux-observable dependency with

"redux-observable-es6-compat": "^1.2.1",

related:
redux-observable/redux-observable#644

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants