Skip to content

Extend ForkedTaskApi to include API #3314

Open
@ericanderson

Description

Having considered porting a lot of code from saga to listeners, I've noticed that I am reaching for the same pattern which is a bit verbose in order to have deeply nested forking:

Example:

function doThingEvent(action, api) {
  const forks = [];
  await api.pause(
    api.fork((forkApi) => doAnotherThing({ api, ...forkApi }))
  );
}

When in reality, the ForkedTaskApi could just include things from the parent, like getState(), dispatch(), and fork(). Not only would this make the code easier to read api.fork(doAnotherThing)), but it would also mean the type API for both the fork and the task is the same.

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions