1.20.4 • Published 7 years ago

react-slex-store v1.20.4

Weekly downloads
49
License
MIT
Repository
github
Last release
7 years ago

CircleCI

React Slex Store

$ npm install react-slex-store

react-slex-store is a connector for slex-store similar to what react-redux is to redux. It allows components to connect to the slex-store to gain access to store data and dispatch.

Example Usage

1. Provide store

import React from 'react'
import ReactDOM from 'react-dom'
import slexStore from 'slex-store'
import { Provider } from 'react-slex-store'

const store =
  slexStore.createStore(
    slexStore.createDispatch({
      reducer: slexStore.createReducer({
        ...
      }),
      middleware: [
        ...
      ],
      sideEffects: [
        ...
      ]
    })
  )

store.subscribe(renderApp)
renderApp()

function renderApp (state) {
  ReactDOM.render((
    <Provider store={store}>
      <App />
    </Provider>
  ))
}

1. Connect to store

// Dumb Component

import React, { Component } from 'react'

class App extends Component {
  render () {
    const { propertyFromStore, wrappedDispatchFunction } = this.props
    return (
      ...
    )
  }
}
export default App

// Connected Component

import App from './App'
import { connect } from 'react-slex-store'

export default connect ((dispatch, getState, ownProps) => {
  const { testStore: { propertyFromStore } } = getState()
  const wrappedDispatchFunction = () => {
    dispatch(...)
  }
  return {
    ...ownProps,
    wrappedDispatchFunction,
    propertyFromStore
  }
})(App)
1.20.4

7 years ago

1.20.3

7 years ago

1.20.2

7 years ago

1.20.1

7 years ago

1.10.8

7 years ago

1.10.7

7 years ago

1.10.6

7 years ago

1.10.5

7 years ago

1.10.4

7 years ago

0.1.0

7 years ago

0.0.9

8 years ago

0.0.8

8 years ago

0.0.7

8 years ago

0.0.6

8 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago