Comparing to Alternatives
This project was created with the intention of improving certain async handling features that I found missing or insufficient in most commonly used scenarios:
Redux Saga | Redux Toolkit | React Use | React Query | Promise Saga | |
---|---|---|---|---|---|
Pluggable | β οΈ | β οΈ | β | β | β |
Cancellable | β οΈ | β οΈ | β οΈ | β οΈ | β |
Type-checking | β οΈ | β | β | β | β |
In-component usage | β | β | β | β | β |
Redux Sagaβ
Redux Saga offers a rich API and has proven itself over time in large-scale applications. However, it lacks proper type inference due to its use of generators, and it is primarily designed for use with Redux.
- β οΈ Pluggable β While Redux Saga is tightly coupled with Redux, it can be extended using channels to work with other event sources.
- β οΈ Cancellable β Although cancellation is possible with additional
AbortController
logic, thereβs no built-in support for canceling all tasks or effects like debouncing (you must substitute it with usingtakeLatest
,delay
) and others. Network requests are not canceled out of the box. - β οΈ Type-checking β All
yield
expressions default toany
unless explicitly typed. Type inference for generator functions is limited. - β In-component usage β Redux Saga lacks built-in hooks, it is a pure side effect tool.
Redux Toolkitβ
Redux Toolkit is an official, powerful abstraction over Redux. It includes handy utilities like createAsyncThunk
for handling async logic, but lacks advanced cancellation features.
- β οΈ Pluggable β Designed for Redux by default, but can be adapted to various use cases, especially in debugging scenarios using time-traveling dev tools.
- β οΈ Cancellable β Each thunk gets its own
AbortSignal
viathunkAPI
, but signals aren't shared across nested contexts. Thunks cannot cancel other thunks natively, nor can they maintain a cancellation tree like Promise Saga. Network request cancellation must be implemented manually. - β Type-checking β Excellent TypeScript support and inference.
- β In-component usage β No built-in hooks for direct use in components.
React Useβ
React Use provides a large set of utility hooks with strong typing. While excellent for small in-component logic, it lacks global coordination and action-based cancellation.
- β Pluggable β Easily usable across the entire React ecosystem.
- β οΈ Cancellable β Cancellable only through basic sync mechanisms; no support for cancelable async workflows.
- β Type-checking β Solid TypeScript support.
- β In-component usage β Fully supports component-based usage.
React Queryβ
React Query is optimized for handling network requests, offering cache management, invalidation, and a powerful API. It doesnβt cover generalized side effects but does its job exceptionally well.
- β Pluggable β Fully compatible across the React ecosystem.
- β οΈ Cancellable β Queries receive
AbortSignal
support, but mutations do not. Cancellations must be handled explicitly. - β Type-checking β TypeScript support is robust and intuitive.
- β In-component usage β Designed for seamless component integration.