Open mrmiguu opened 5 years ago
The pattern would look something like this:
func main() {
coco.Globals(NewGlobals())
coco.Render(NewApp())
}
and
type Up struct {
Globals
}
func (u Up) OnUpClick() {
u.Cocos = append(u.Cocos, "🥥")
coco.Set(u)
}
Currently patching adds new listeners on the new component instance/copy. So when they're fired again, they're using the most up-to-date instance (e.g. coco.Set(...)
).
To cause updating of globals to refresh other components embedding them, this would require new listeners to be assigned for all components using those globals; component instances embedding globals can only use the new context (w/ the new global) for the listeners if they're reassigned.
Allow users to embed a global store in their components, having them diff/recompile on mutation. This should be sprinkled intermittently throughout a component hierarchy and patch as needed.