dannypsnl / Redux
Licence: mit
redux implementation in Go/Rust
Stars: ✭ 40
Projects that are alternatives of or similar to Redux
Stateview
✨ StateView is an invisible, zero-sized View that can be used to lazily inflate loadingView/emptyView/retryView at runtime.
Stars: ✭ 573 (+1332.5%)
Mutual labels: state
Salty Whales
Extra ordinary Docker images for Salt. Whales love Salt.
Stars: ✭ 5 (-87.5%)
Mutual labels: state
Reo
🍯 regularjs and stateman based spa framework, inspired by redux, vuex and choo
Stars: ✭ 14 (-65%)
Mutual labels: state
Pullstate
Simple state stores using immer and React hooks - re-use parts of your state by pulling it anywhere you like!
Stars: ✭ 683 (+1607.5%)
Mutual labels: state
Statty
A tiny and unobtrusive state management library for React and Preact apps
Stars: ✭ 516 (+1190%)
Mutual labels: state
Sticky State
StickyState is a high performant module making native position:sticky statefull and polyfilling the missing sticky browser feature
Stars: ✭ 692 (+1630%)
Mutual labels: state
Revived
A redux-inspired predictable state container for python
Stars: ✭ 12 (-70%)
Mutual labels: state
Little State Machine
📠 React custom hook for persist state management
Stars: ✭ 654 (+1535%)
Mutual labels: state
Stent
Stent is combining the ideas of redux with the concept of state machines
Stars: ✭ 681 (+1602.5%)
Mutual labels: state
State Binder
StateBinder is a tiny library for view state management
Stars: ✭ 24 (-40%)
Mutual labels: state
Concent
State management that tailored for react, it is simple, predictable, progressive and efficient.
Stars: ✭ 882 (+2105%)
Mutual labels: state
Mithril Data
A rich data model library for Mithril javascript framework
Stars: ✭ 17 (-57.5%)
Mutual labels: state
Tng Hooks
Provides React-inspired 'hooks' like useState(..) for stand-alone functions
Stars: ✭ 954 (+2285%)
Mutual labels: state
Pytest Patterns
A couple of examples showing how pytest and its plugins can be combined to solve real-world needs.
Stars: ✭ 24 (-40%)
Mutual labels: state
redux
This is a redux implementation in Go/Rust.
Install
$ go get github.com/dannypsnl/[email protected]
Usage
import (
// must import, else go module would think following package is a module
_ "github.com/dannypsnl/redux/v2"
// v2 store
"github.com/dannypsnl/redux/v2/store"
// v2 rematch(optional)
"github.com/dannypsnl/redux/v2/rematch"
)
Basic example
// As you can see, you don't need to checking nil or not now
// Now redux-go will initial the state with zero value of that type
func counter(state int, action string) int {
switch action {
case "INC":
return state + 1
case "DEC":
return state - 1
default:
return state
}
}
func main() {
// redux/v2/store
store := store.New(counter)
store.Dispatch("INC")
fmt.Printf("%d\n", store.StateOf(counter)) // should print out: 1
}
More stunning
func main() {
counter := func(state, payload int) int {
return state + payload
}
store := store.New(counter)
store.Dispatch(100)
store.Dispatch(-50)
fmt.Printf("%d\n", store.StateOf(counter)) // should print out: 50
}
And more...
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
}
Then let's have a party
type CountingModel struct {
Reducer
State int
Increase *rematch.Action `action:"IncreaseImpl"`
}
func (c *CountingModel) IncreaseImpl(s, payload int) int {
return s + payload
}
func main() {
c := &CountingModel {
State: 0,
}
store := store.New(c)
store.Dispatch(c.Increase.With(30))
store.Dispatch(c.Increase.With(20))
fmt.Printf("result: %d\n", store.StateOf(c)) // expect: 50
}
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].