redux-subspace

npm version npm downloads License: MIT

All Contributors PRs Welcome

Watch on GitHub Star on GitHub

This is a library to help build decoupled, componentized Redux apps that share a single global store.

Installation

npm install --save redux-subspace react-redux-subspace

Quick Start

import React from 'react'
import { createStore, combineReducers } from 'redux'
import { Provider } from 'react-redux'
import { namespaced } from 'redux-subspace'
import { SubspaceProvider } from 'react-redux-subspace'
import { TodoApp, todoReducer } from './todoApp'
import { CounterApp, counterReducer } from './counterApp'

const rootReducer = combineReducers({
  todo: todoReducer
  counter1: namespaced('counter1')(counterReducer),
  counter2: namespaced('counter2')(counterReducer)
})

const store = createStore(rootReducer)

const App = () => (
  <Provider store={store}>
    <SubspaceProvider mapState={(state) => state.todo}>
      <TodoApp />
    </SubspaceProvider>
    <SubspaceProvider mapState={(state) => state.counter1} namespace="counter1">
      <CounterApp />
    </SubspaceProvider>
    <SubspaceProvider mapState={(state) => state.counter2} namespace="counter2">
      <CounterApp />
    </SubspaceProvider>
  </Provider>
)

Documentation

Packages

Upgrading From Version 1 to Version 2

When upgrading to version 2 of Redux Subspace, refer to the migration guide to work through all the breaking changes.

Media

Contributors

Thanks goes to these wonderful people (emojis):


Michael Peyper

💬 🐛 💻 📖 💡 🤔 🚇 👀 📦 📢 ⚠️ 🔧

Jonathan Peyper

💬 💻 🤔 👀 ⚠️

Vivian Farrell

🤔 📦 👀 📢

Emily Rosengren

📢

Morgan Larosa

🚇

Amit Kothari

💻 💡

Riku Rouvila

💻 📖 ⚠️

Michael

💻

James Adams

📖

Lee Kyles

💻 ⚠️

Evert Bouw

💻 ⚠️

Paweł Bród

🐛

majo44

🐛 💻 ⚠️

Garth Newton

🐛 📖

Mateusz Burzyński

🔧

psamusev

🐛

Jay Phelps

👀

Mark Erikson

📢

This project follows the all-contributors specification. Contributions of any kind are welcome!

results matching ""

    No results matching ""