Socket
Socket
Sign inDemoInstall

iron-connector

Package Overview
Dependencies
18
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    iron-connector

Lightweight multi-instance redux library based on react-redux


Version published
Maintainers
1
Install size
17.5 kB
Created

Readme

Source

iron-connector

Lightweight multi-instance redux library based on react-redux.The main purpose of iron-connector is to better reuse state logic.

Solution

We provide two different ways to construct Redux multi-instance applications, including ironReducer and Connector. The Connector's method requires:

  • React >= 16.8
  • react-redux >= 7.0

ironReducer

ironReducer's purpose is to strengthen the reducer, and construct multi-instance redux applications. you can try ironReducer - Demo

The key code:

const reducer = {
  addTodo: ironReducer(originReducer, "addTodo"),
  addPush: ironReducer(originReducer, "addPush")
};

function TodoApp() {
  return (
    <div>
      <AddTodo as="addTodo" />
      <AddPush as="addPush" />
    </div>
  );
}

Connector

Connector's purpose is to add Redux instances dynamically. you can try Connector - Demo

The key code:

// 根目录store.tsx
import { createStore } from "redux";
import { ironStore, Connecor } from "iron-connector";

// 对redux的createStore增强
const store = ironStore(createStore)(rootReducer);

// 使用Connecor对组件进行封装,绑定动态redux状态
export default () => {
  return (
    <Connector as="addPush" reducer={reducer} actions={actions}>
      <AddPush />
    </Connector>
  );
};

license

MIT

Keywords

FAQs

Last updated on 25 Aug 2019

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc