Skip to content

Extend createAsyncAction API to be able to carry over request information to success and failure handlers #73

@abersnaze

Description

@abersnaze

I have a bunch of epics that have a similar pattern.

export const fooAction = createAsyncAction(
    'FOO_INIT',
    'FOO_DONE',
    'FOO_ERROR')<Foo, Bar, Error>();

The problem that I'm having is that the Error type loses the request value (of type Foo). To properly mutated the state in the reducer I've had to compose the Error and Foo together in the epic. So the async action creator now looks like this.

export const fooAction = createAsyncAction(
    'FOO_INIT',
    'FOO_DONE',
    'FOO_ERROR')<Foo, [Foo, Bar], [Foo, Error]>();

I was wondering if the request payload can be carried over to the success and failure actions?

InputAction would be the same { type: string, payload: I }
OutputAction would be { type: string, payload: O, request: I }
ErrorAction would be { type: string, payload: E, request: I }

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions