Skip to content

Add async epic helper#272

Open
apples-kksk wants to merge 2 commits into
piotrwitek:masterfrom
apples-kksk:add-create-async-epic
Open

Add async epic helper#272
apples-kksk wants to merge 2 commits into
piotrwitek:masterfrom
apples-kksk:add-create-async-epic

Conversation

@apples-kksk
Copy link
Copy Markdown

@apples-kksk apples-kksk commented May 9, 2026

Closes #162.

Adds createAsyncEpic, a redux-observable-compatible helper for async action objects. It listens for request actions, runs a typed handler, maps emitted values to success actions, maps errors to failure actions, and cancels active work when an optional cancel action is emitted.

Notes:

  • Uses RxJS types for the public epic shape, but avoids runtime top-level RxJS imports in the bundled package.
  • Adds tests for success, promise completion, error mapping, custom mapError, cancellation, and type inference.
  • Documents usage in the redux-observable tutorial and API section.

Verification:

  • npm run ci-check
  • NODE_OPTIONS=--openssl-legacy-provider npm run build
  • git diff --check

IssueHunt Summary

Referenced issues

This pull request has been submitted to:


Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the createAsyncEpic helper, which simplifies the creation of redux-observable epics by automatically handling the request, success, failure, and cancellation lifecycle of async actions. The implementation includes new tests, documentation, and updates to dependencies. Review feedback highlights opportunities to improve compatibility with environments lacking Symbol support, optimize iteration logic when observers are closed, and enhance type safety for error mapping. It is also recommended to explicitly document the 'switch' strategy behavior used for managing concurrent requests.

Comment thread src/create-async-epic.ts
Comment thread src/create-async-epic.ts Outdated
Comment thread src/create-async-epic.ts
Comment thread README.md Outdated
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

Successfully merging this pull request may close these issues.

Add a generic redux-observable factory automatically handling async-actions - createAsyncEpic

2 participants