1.0.0 • Published 9 years ago

tinyflux v1.0.0

Weekly downloads
29
License
MIT
Repository
github
Last release
9 years ago

TinyFlux

TinyFlux is a predictable state container for JavaScript apps.

It is very very tiny,just 150 line source code and has no dependencies

You can read an overview of ReFlux here

╔═════════╗       ╔════════╗       ╔═════════════════╗
║ Actions ║──────>║ Stores ║──────>║ View Components ║
╚═════════╝       ╚════════╝       ╚═════════════════╝
     ^                                      │
     └──────────────────────────────────────┘

Hower when we write more reflux , we will find action is more unnecessary.

action is almost equal the store method!

we always copy store method to action for declare action,so unnecessary.

╔════════╗       ╔═════════════════╗
║ Stores ║──────>║ View Components ║
╚════════╝       ╚═════════════════╝
     ^                   │
     └───────────────────┘

So this is the tinyflux architecture

we no longer declare action ever

action is generate by store method!

less is more!

Install

npm install --save tinyflux

Examples

How To Use

ONLY 1 MINUTE , YOU KNOW EVERYTHING ABOUT TINYFLUX

Store

import TinyFlux from 'tinyflux';

//1.create Store by TinyFlux.createStore
//2.set your action function
//3.set your get function
//ok that's all
let Store = TinyFlux.createStore({
	getInitialState(){
		return 0;
	},
	increment(){
		this.state++;
	},
	decrement(){
		this.state--;
	},
	get(){
		return this.state;
	}
});
export default new Store();

Component

import TinyFlux from "tinyflux"
import React from "react"
import Store from "./store"

//1.create Component by TinyFlux.createComponent
//2.create mapStateToProps for map store data to component data
//3.connect 1 and 2 
//ok that's all
let Component = TinyFlux.createComponent({
	render(){
		return (
			<div>
				<div>{this.props.counter}</div>
				<button onClick={Store.increment}>increment</button>
				<button onClick={Store.decrement}>decrement</button>
			</div>
		);
	}
});

function mapStateToProps(){
	return {
		counter:Store.get()
	}
}
export default TinyFlux.connect(mapStateToProps,Component);

License

MIT

1.0.0

9 years ago

0.5.6

9 years ago

0.5.5

9 years ago

0.5.4

9 years ago

0.5.3

9 years ago

0.5.0

9 years ago

0.4.3

9 years ago

0.4.2

9 years ago

0.4.1

9 years ago

0.4.0

9 years ago

0.3.3

9 years ago

0.3.2

9 years ago

0.3.1

9 years ago

0.3.0

9 years ago

0.2.8

9 years ago

0.2.7

9 years ago

0.2.6

9 years ago

0.2.5

9 years ago

0.2.4

9 years ago

0.2.3

9 years ago

0.2.2

9 years ago

0.2.1

9 years ago

0.2.0

9 years ago

0.1.0

9 years ago