1.2.0 • Published 5 years ago

redux-sam v1.2.0

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

redux-sam

npm package

redux-sam is a middleware of Redux for managing state like Vuex.

NPM version NPM Downloads npm.io

Full Documentation

redux-sam


Installation

$ npm install --save redux redux-sam react-redux

CommonJS style with npm

import { createStore } from 'redux-sam';
import createLogger from 'redux-sam/logger';

const { store } = createStore({
  state: { ... },
  mutations: { ... },
  actions: { ... },
  modules: { ... },
  plugins: [process.env.NODE_ENV !== 'production' && createLogger()]
}, Component);

export { store };

Or

import { createStore, applyMiddleware } from 'redux';
import { Sam, reducer, middleware } from 'redux-sam';
import createLogger from 'redux-sam/logger';

const sam = new Sam({
  state: { ... },
  mutations: { ... },
  actions: { ... },
  modules: { ... },
  plugins: [process.env.NODE_ENV !== 'production' && createLogger()]
});
const store = createStore(
  reducer(sam), 
  sam.state, 
  applyMiddleware(middleware(sam))
);

export { store };

Load redux-sam via classical <script> tag

<script src="https://cdn.jsdelivr.net/npm/redux-sam/iife.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/redux-sam/logger.iife.min.js"></script>
<script>
  // window.reduxSam
  var createStore = reduxSam.createStore;

  const { store } = createStore({
    state: { ... },
    mutations: { ... },
    actions: { ... },
    modules: { ... },
    plugins: [process.env.NODE_ENV !== 'production' && createSamLogger()]
  }, Component);
</script>

Or

var createStore = Redux.createStore;
var applyMiddleware = Redux.applyMiddleware;
var Sam = reduxSam.Sam;
var reducer = reduxSam.reducer;
var middleware = reduxSam.middleware;

var sam = new Sam({
  state: { ... },
  mutations: { ... },
  actions: { ... },
  modules: { ... },
  plugins: [process.env.NODE_ENV !== 'production' && createLogger()]
});
const store = createStore(
  reducer(sam), 
  sam.state, 
  applyMiddleware(middleware(sam))
);

Examples

Running the examples:

$ git clone https://github.com/react-hobby/redux-sam
$ npm install
$ npm run dev

License

MIT

1.2.0

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.1-beta.1

5 years ago

1.1.0

5 years ago

1.0.2

5 years ago

1.0.2-beta.1

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

1.0.0-beta.2

5 years ago

1.0.0-beta.1

5 years ago