@myoshida/fluxion
v0.2.1
Published
An EventEmitter-based layman's Flux implementaion
Downloads
3
Maintainers
Readme
Fluxion
An EventEmitter-based layman's Flux implementaion
Installation
npm install @myoshida/fluxion --save
Basic Usage ("Hello World")
import React from 'react';
import ReactDOM from 'react-dom';
import { Component, createStore, next } from 'fluxion';
class MyComponent extends Component {
render() {
return (
<div>
<span>Counter: {this.props.count} </span>
<button onClick={() => this.dispatch('inc')}>INC</button>
</div>
);
}
}
MyComponent.propTypes = {
count: React.PropTypes.number.isRequired,
};
const store = createStore({
actions: {
inc: ({ val = 1 }) => {
store.update(state => {
const { count } = state;
return next(state, { count: count + val });
});
},
},
renderer(state, provider) {
return ReactDOM.render(
provider(<MyComponent {...state} />),
document.getElementById('example'));
},
});
store.update(() => { count: 0 }); // this fires rendering
Release History
- 0.2.1 Maintenance release
- 0.2.0 Added some APIs
- 0.1.0 Initial release (preliminary)