It is always our job to write actions, action types and reducers to work with redux. However they serve for one thing and they should not be spread. redux-lightweight library allows you to write your reducers, actions and action types in one class.
class Counter {
state = {
number: 0;
}
increment(amount) {
return this.state.number + amount;
}
}
As you see all redux stuff is inside one class.
Hope, it will help you with working redux easier.
doniyor2109 / redux-lightweight
Write one business logic instead of writing actions, action types and reducers
redux-lightweight
This library generates actions creators, action types and reducers for you. It uses class as a syntactic sugar for generating actions and reducers.
Table of Contents
Introduction
Motivation
Redux is great library which solves data management. However it introduces some boilerplate. In order to add one business logic, developer must create 3 different things (action type, action creator, reducer) and they do one thing together. That is why I have decide to create utility that allows declare them in one place. One business logic should be declared in one place.
This library is inspired by redux-actions and mobx
Getting Started
Installation
$ npm install --save redux-lightweight
or
$ yarn add redux-lightweight
Usage
Create class that has state
property asβ¦
Top comments (4)
I like the motivation of the project of co-locating all business logic in one place π
Maybe you can request to add your library to React State Museum for others to check out π
GantMan / ReactStateMuseum
A whirlwind tour of React state management systems by example
One Packing List App Written in:
Examples to help portray the how, why, which, pros, and cons of various state management systems in the React ecosystem.
Every app is meant to be small, simple, and the same as each other. The only difference shouldβ¦
It is on React State Museum ππ
Woo hoo~
That is great idea. Thanks.