Skip to content
/ reo Public

🍯 regularjs and stateman based spa framework, inspired by redux, vuex and choo

License

Notifications You must be signed in to change notification settings

fengzilong/reo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

94 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

reo

build

inspired by redux, vuex and choo

Overview

import reo from 'reo'

const app = reo()
app.use( plugin )
app.model( ... )
app.actions( ... )
app.getters( ... )
app.router( ... )
app.start( '#app' )

Real world example

import reo from 'reo'

const app = reo()

app.model( {
	name: 'counter',
	state: { count: 0 },
	reducers: {
		add( state ) {
			state.count++
		},
		minus( state ) {
			state.count--
		}
	}
} )

app.getters( {
	count: state => state.counter.count
} )

app.actions( {
	add( { commit } ) {
		commit( 'counter/add' )
	},
	minus( { commit } ) {
		commit( 'counter/minus' )
	}
} )

const Counter = {
	getters: {
		c: 'count'
	},
	template: `
		<button on-click="{ this.dispatch( 'minus' ) }">-</button>
		{ c }
		<button on-click="{ this.dispatch( 'add' ) }">+</button>
	`,
}

app.router( {
	routes: [
		{ path: '/', component: Counter }
	]
} )

app.start( '#app' )

License

MIT © fengzilong

About

🍯 regularjs and stateman based spa framework, inspired by redux, vuex and choo

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published