New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

warped-reducers

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

warped-reducers

Compile a standard Redux reducer from a brief definition

  • 1.0.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

Warped Reducers

Build Status Greenkeeper Enabled

Compile a standard Redux reducer from a brief definition.

Usage in Node depends on --experimental-modules. With older Node versions, use esm.

API

createReducer :: String -⁠> StrMap (b -⁠> a -⁠> a) -⁠> { types :: StrMap String, actions :: StrMap (b -⁠> { type :: String, payload :: b }), reducer :: (a, b) -⁠> a }

This is also the default export from this module.

Given a String representing the namespace, and a StrMap of action handlers, returns a Record containing a single reducer, and a new StrMap mapping the original keys to canonical identifiers of the types that the reducer can handle.

An action handler is a curried function that takes the payload of the action first, and the state second, and should return a new state. We recommend usings Optics, such as the lens-related functions from Ramda, to define the reducers - the signature of action handlers is designed to align perfectly with the signature of functional utilities.

const setMyProp = myProp => state => Object.assign ({}, state, {myProp});
createReducer ('MyNamespace') ({setMyProp});
noopAction :: a -⁠> b -⁠> b

A conviently named function that does nothing to your state.

To be used when you need to define an action type which should not affect the state, but can be used as a message to your Redux side-effect handling middleware.

> noopAction ({do: 'nothing'}) ({myState: 'whatever'})
{myState: 'whatever'}

FAQs

Package last updated on 23 Jul 2018

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