1.0.14 • Published 6 years ago

state-observer v1.0.14

Weekly downloads
-
License
ISC
Repository
-
Last release
6 years ago

Interface

createStore (defaultState: Object) => {
	getState: () => Object;
	setState: (newState:  Object);
	connect: (mapStateToProps:  Object, func:  Function);	
}

Examples

  1. Create default store state
const defaultState = {
	foo:  'bar', 
	fiz:  'buzz'
}
  1. Create Store
const store = createStore(defaultState);
  1. Connect function which triggered by a change of the part of store
//part of store
const mapStateToProps =  (state)  =>  ({
	foo: state.foo
})

//triggered function
const func = ({foo})  =>  {
	console.log('triggered')
}

store.connect(mapStateToProps, func)
  1. Change state
store.setState({foo:  'biba'})
  1. Connected func triggered
expected output: 'triggered'
1.0.11

6 years ago

1.0.14

6 years ago

1.0.13

6 years ago

1.0.12

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago