mvflux
v0.1.1
Published
Flux inspired, minimal boilerplate state management.
Downloads
12
Maintainers
Readme
Mvflux
To install run:
npm install --save mvfluxor
yarn add mvfluxUsage
Store code:
import { Store } from 'mvflux'
class CustomStore extends Store {
data = {
counter: 0
}
increment = () => {
this.setData(data => ({ counter: data.counter + 1 }));
}
}
export default new CustomStore;Component code:
import React from 'react'
import { connect } from 'mvflux'
import MyCustomStore from './customStore'
class MyComponent extends React.Component {
...
}
export default connect(MyCustomStore)(MyComponent)Inside MyComponent you can use the data from the store (in this case this.props.counter) and running MyCustomStore.increment() will rerender the component with the new, incremented counter.
