Functional type-safe Flux standard utilities
The only completely functional type-safe approach to Flux that its main goals are to diminish types verbosity, repetition and complexity without losing any type information (type-safe alternative of redux-actions).
Behold, the art of Deox:
- Minimalist (almost no import cost) - checkout Bundle Phobia.
- Simple - focused on self-declarative API.
- Secure - complete test-suits for all of the edge and corners.
The most common complaint about Flux is how it makes you write a lot of boilerplate. Also, existing solutions like redux-actions or redux-starter-kit are not type-safe by the idea (although there are some other ideas with classes 😱).
So, this is where Deox takes place to make maintenance of Flux architecture simpler and more readable by sticking to functional programming paradigm.
You can install Deox package by running:
# YARNyarn add deox# NPMnpm install deox
Typescript tip: notice that Deox internally uses some ES2015 type definitions to represent better developer experience. So if you are using
es5, be sure
es2015lib has been added in tsconfig.json:
If you don't use module bundler, it's also fine. The Deox NPM package also includes a production minified UMD build that makes Deox available as global variable called
window.Deox; you can add it simply to your page via following script tag:
counterReducerundefined, increment //=> 1counterReducerundefined, decrement //=> -1counterReducer3, reset0 //=> 0
- Getting started
- API reference
redux-starter-kit are neat and almost similar to each other.
deox is similar to those projects in the idea, but not in implementation and promise.
The main goal of
deox is to use the full power of type-safety and type inferring in typescript.
If you have some experience with those libraries, the following piece of code should be familiar for you:
This is horrible; Why define a type like actions that a reducer can handle?! It's completely obvious which actions a reducer handles.
On another hand there is a big problem with the pattern that
redux-starter-kit follows. it's lack of correct type for action handler:
Type of action parameter in
addTodo action handler is overall
Actions type. It's inaccurate!
And this is where Deox comes in action and practice:
That's it. Thanks to typescript type inferring there is no type verbosity at all. You can be sure
todos reducer have the proper type of state and actions that it can handle.
And every action handler's type is just what it should be. It's completely safe and correct!
What's the difference with
typesafe-actions is a great project that Deox carries huge inspiration from that.
typesafe-actions doesn't have any plan for a complete set of utilities (specially reducers); It's all about actions and action creators.
Deox uses Semantic Versioning 2.0.0
Please read through our contributing guidelines.
- redux-actions - Flux Standard Action utilities for Redux
- typesafe-actions - Typesafe Action Creators for Redux / Flux Architectures (in TypeScript)
Deox is released under MIT license.