Skip to content

:atom: Redux reducer and actions to "on/off" state machines

Notifications You must be signed in to change notification settings

bshuster-repo/redux-onoff

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

alt redux-onoff-tiny REDUX ON/OFF

alt redux-onoff-tiny

This repository contains redux-onoff source code and currently hosted on Github. The main purpose of redux-onoff is to easily set toggle options to components connected to a Redux store.

It will be very useful for components like dialog window, switch button and etc.

Installation

  • yarn

    yarn add redux-onoff
  • npm

    npm install redux-onoff

Getting Started

// in src/some/reducer.js
import { hor } from "redux-onoff";

const counterInit = { counter: 0 };
const someReducer = (state = counterInit, action = {}) => { ... };
export const newSomeReducer = hor("some")(someReducer);

// in src/App.js
import React, { Component } from "react";
import { connect } from "react-redux";
import { bindActionCreators } from "redux";
import { toggleAction, setAction } from "redux-onoff";
import * as actions from "./yourReduxActions";

class App extends Component {
  ...
}

export default connect(
  mapStateToProps,
  dispatch => bindActionCreators(
    {
      ...actions,
      toggleWindow: toggleAction("some"),
    },
    dispatch
  )
)(App);

Releases

No releases published

Packages

No packages published