apemanstore
apeman flavored redux store.
Installation
$ npm install apemanstore --save
Usage
'use strict'
const apemanstore = require('apemanstore')
apemanstore.define(
(store, action) => {
/* ... */
}
).assign(
{
/* ... */
}
)
const SignStore = apemanstore.define(
// Define reducer
(state, action) => {
switch (action.type) {
case 'SET':
return action.signed
case 'DEL':
return null
default:
return state
}
}
).assign(
// Assign custom props.
{
setSign(signed) {
const s = this
s.dispatch({
type: 'SET',
signed: signed
})
return s
},
getSign() {
const s = this
return s.getState() || null
},
delSign() {
const s = this
s.dispatch({ type: 'DEL' })
return s
}
}
)
let store = new SignStore({})
// Subscribe change
store.subscribe(() => {
let sign = store.getSign()
console.log(sign)
})
store.setSign({ id: 1 })
License
This software is released under the MIT License.