-
Notifications
You must be signed in to change notification settings - Fork 1
Home
Wallant provides persistant, auto-validate, and predictable state container for React Native, it can be slower than Redux or React Context, we sacrificed speed for store maintainability. The main advantages of wallant are in it's easy of use, and its ability to disconnect and reconnect from any component, integrating wallant in an existing project is much easier than integrating Redux or Context, getting rid of Wallant is also easy, due to that connects with the main components without modifying the or insert props, all the data exist outside the components, and are consumed directly from the store.
All context from store, connect, consume and hooks.
About data, how mutate, and how consume
Dispatch actions in store
Data storage it's easy with Wallant
Take state data and expose as new data in the same state
Break bad states, and avoid useless renders
Design pattern recomended for big stores
/* store.js */
import Wallant from 'wallant'
const store = new Wallant({
state: {
count: 0
},
actions: {
increment () {
// ss === setState => true
this.ss({
count: count++
})
}
}
})
export default store
/* App.js */
// import React and React Native and stuffs
import store from './store'
class App extends Component {
componentDidMount () {
/*
* Store takes component instance
* and can update when store change
*/
store.use(this)
}
render () {
<View>
<Text>Number is { store.state.count }</Text>
<Button
title="increment counter"
onPress={ store.action.increment }/>
</View>
}
}
// styles, exports, and stuffs