DEV Community

doniyor2109
doniyor2109

Posted on

New redux-lightweight library to help reduce redux boilerplate

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.

GitHub logo 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.

Build Status codecov PRs Welcome GitHub

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)

Collapse
 
dance2die profile image
Sung M. Kim

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:

Technology React React Native
setState
React 16.x Context
Redux
MobX
unstated
MobX-State-Tree
GraphQL Apollo + Amazon AppSync
apollo-link-state
setState + react-automata
Freactal
ReduxX
pure-store
ReactObservableStore
react-easy-state
rematch
unistore
Microstates
react-recontext
remx Coming Soon - Contribute Here?
simple-remx
constate Coming Soon - Contribute Here?
controllerim Coming Soon - Contribute Here?
immer
parket Coming Soon - Contribute Here?
react-contextual Coming Soon - Contribute Here?
react-copy-write Coming Soon - Contribute Here?
react-simplified
reim Coming Soon - Contribute Here?
React 16.x Context + Redux Coming Soon - Contribute Here?
ReComponent Coming Soon - Contribute Here?
undux Coming Soon - Contribute Here?
React 16.7.0-alpha useState Hook Coming Soon - Contribute Here?

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…

Collapse
 
doniyor2109 profile image
doniyor2109

It is on React State Museum 🎉🎉

Collapse
 
dance2die profile image
Sung M. Kim

Woo hoo~

woohoo

Collapse
 
doniyor2109 profile image
doniyor2109

That is great idea. Thanks.