This repository has been archived by the owner on Nov 13, 2022. It is now read-only.
Releases: dannypsnl/redux
Releases · dannypsnl/redux
v2.2.3
v2.2.2
v2.2.1
v1.5.3
v2.2.0
At before we use rematcher.Action(rematcher.ReducerMethod).With(payload)
to generate our action for dispatching, now we just add a field with action tag, the format is: action:"ReducerMethodName"
Example:
type CountModel struct {
Reducer
State int
Increase *rematch.Action `action:"IncreaseMethod"`
}
func (c *CountModel) IncreaseMethod(s, payload int) int {
return s + payload
}
// main
c := &CountModel{State: 0}
store.New(c)
store.Dispatch(c.Increase.With(10))
fmt.Printf("%d", store.StateOf(c)) // 10
v2.1.2
v2.1.1
v2.1.0
feature: rematch, ref #48
type CountingModel struct {
rematch.Reducer
State int
}
func (cm *CountingModel) Increase(s, payload int) int {
return s + payload
}
func (cm *CountingModel) Decrease(s, payload int) int {
return s - payload
}
func main() {
c := &CountingModel{
State: 0,
}
store := store.New(c)
store.Dispatch(c.Action(c.Increase).With(100))
store.Dispatch(c.Action(c.Decrease).With(50))
fmt.Printf("result: %d\n", store.StateOf(c)) // expect: 50
}