Logo

dev-resources.site

for different kinds of informations.

New redux-lightweight library to help reduce redux boilerplate

Published at
12/20/2018
Categories
react
redux
actions
reducer
Author
doniyor2109
Categories
4 categories in total
react
open
redux
open
actions
open
reducer
open
Author
11 person written this
doniyor2109
open
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;
    }
}

Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

or

$ yarn add redux-lightweight
Enter fullscreen mode Exit fullscreen mode

Usage

Create class that has state property as…

Featured ones: