~/STATE · 徵集中
狀態管理
NSGo 的狀態是一張在 Go 中執行的響應式圖:signal 保存值,memo 由它衍生,畫面上只有讀到這個值的部分才會更新。社群方案在其上構建。
count := core.NewSignal(cx, 0)
core.Text{ContentFunc: func() string {
return fmt.Sprintf("%d", count.Get())
}}
count.Set(5)
count.Update(func(n int) int { return n + 1 })
Components and state ↗成為第一個收錄的狀態方案
例如:以 signal 為基礎的 store、復原與重做、在裝置上持久化或跨裝置同步的狀態。