Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

redux-fluent

Package Overview
Dependencies
Maintainers
2
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redux-fluent

Enjoy Redux - Less Scaffolding / More Functional

  • 0.5.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8
decreased by-27.27%
Maintainers
2
Weekly downloads
 
Created
Source

Redux Fluent redux-fluent

Build Status npm version License Conventional Commits npm downloads Maintainability Test Coverage

Tiny and eloquent way to manage a redux-like state manager (~3K, dependencies free, definitions included).

Try it out on RunKit

Documentation

Motivation

Redux is great, every recent web application has most likely been built on top of it. How can we make it even better?

  • λ Go Functional, Everything is a function and reducers are built by function composition rather than piling up if and switch-case statements: Let's introduce Redux Fluent Reducers.
  • Reducers at scale, due to being handling multiple actions, reducers tend to grow and become difficult to maintain: Let's introduce Redux Fluent Action Handlers.
  • Less boilerplate, Flux architecture is usually verbose and some of their concepts, such as Action, Action Type and Action Creator could all be implemented in a single entity: Let's introduce Redux Fluent Actions.
  • FSA compliance, FSA Actions may have a error: boolean field, which indicates whether the action represents a failure or not. Respecting this pattern leads to a series of if statements inside reducers, compromising both readability and maintainability, so the community normally tends to split error and failures into two separate actions (eg: ADD_TODO_SUCCESS and ADD_TODO_ERROR) which reduces cognitive complexity on one hand but produces even more boilerplate on the other. Let's embrace FSA and abstract error handling with filterable action handlers.

Installation

yarn add redux-fluent

Getting Started

/** todos.actions.js **/
import { createAction } from 'redux-fluent';

export const addTodo = createAction('todos | add');
/** todos.reducer.js **/
import { createReducer, ofType } from 'redux-fluent';
import * as actions from './todos.actions.js';

const addTodo = (state, { payload }) => state.concat(payload);

export const todos = createReducer('todos')
  .actions(
    ofType(actions.addTodo).map(addTodo),
    /* and so on */
  )
  .default(() => []); 
/** application.js **/
import { createStore } from 'redux';
import { combineReducers } from 'redux-fluent';
import * as actions from './todos.actions.js';
import { todos } from './todos.reducer.js';

const rootReducer = combineReducers(todos, ...);
const store = createStore(rootReducer);
store.getState(); // { todos: [] }

store.dispatch(actions.addTodo('1'));
store.getState(); // { todos: [1] }

Keywords

FAQs

Package last updated on 03 Mar 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc