Simple state and logic management library for modern React apps.
$ yarn add tinysaga
Comes with TypeScript typings out of the box, as well as ESM support and tree shaking.
Out of the box, Tinysaga includes the following pieces:
Storeclass which allows the user to update state and subscribe to changes. Its view-facing API is identical to that of Redux.
- React integration via a Store
- Logic handling infrastructure via familiar
- Builtin strong Action typing on all of the above to make dispatching and handling actions more fluent in TypeScript.
Comparison to Redux-Saga
Redux-Saga is a great library which allows applications to manage the complex state updates and side effects that happen in many React-Redux applications. It is a crucial part of the current frontend software stack.
However, the library itself is quite complex, which can cause problems in the following ways:
- Developers onboarding into a Saga-based codebase may need to understand the Saga fork and threading model pretty deeply in order to contribute to the code. This creates cognitive overhead for even the best developers.
- The effect model can be surprising to unravel. For example, sending a callback to external code becomes a lot more complex as developers need to reason about how to invoke effects from within the callback.
- The syntax itself can be challenging and unfamiliar, such as
yield*, or why you would want to
yield takeinside of a
- The code can be very hard to debug, especially in modern compile-to-ES6 toolchains where the generators become obfuscated. Stepping through code can be a chore, and profiling code through many layers of effect realization can be a nightmare.
Tinysaga supports most of the common
on() workflows, along with
takeAdvanced() sugar, without necessitating generators through your codebase.