1.0.14 • Published 4 years ago

state-observer v1.0.14

Weekly downloads
-
License
ISC
Repository
-
Last release
4 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

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago