Skip to content

Request for articles/epics.md #553

Description

@westandy-dcp

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)
    )

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions