Skip to content

Repository files navigation

barracks-react

An action dispatcher for React that provides for unidirectional dataflows. Intended to be very small and provide a small amount of cognative overhead in providing an "actions up, data down" type model for React. Built on top of barracks.

Usage

constReact=require('react')constReactDOM=require('react-dom')constbearact=require('./')constmodel={namespace: 'example',state: {hello: ''},reducers: {setHello: (state,data)=>({hello: data.value})}}constMain=React.createClass({handleChange: function(evt){this.props.send('setHello',{value: evt.target.value})},render: function(){returnReact.createElement('div',{},[React.createElement('h1',{},`Hello, ${this.props.model.hello}`),React.createElement('br',{},null),React.createElement('input',{value: this.props.model.hello,onChange: (evt)=>this.handleChange(evt)},null)])}})constmain=React.createElement(bearact(Main,model))constmount=document.createElement('div')document.body.appendChild(mount)ReactDOM.render(main,mount)

License

Copyright © 2016 Scripto, licenced under the Apache-2.0 license

About

Flux off even faster!

Resources

Stars

5 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages