diff --git a/nodes.go b/nodes.go index 62f3659..7d214f7 100644 --- a/nodes.go +++ b/nodes.go @@ -18,7 +18,7 @@ func (n Node) mount(parent Control) { } } -func (n Node) updateChild(idx int, new Control) { +func (n *Node) updateChild(idx int, new Control) { old := n.Children[idx].Content if old == nil && new == nil { return @@ -48,7 +48,7 @@ func (n Node) updateChild(idx int, new Control) { } } -func (n Node) Update(other Node, parent Control) { +func (n *Node) Update(other Node, parent Control) { if n.Content != nil && other.Content == nil { if unmountable, ok := n.Content.(Unmountable); ok { unmountable.Unmount() diff --git a/rendercontext.go b/rendercontext.go index d2eed03..6775522 100644 --- a/rendercontext.go +++ b/rendercontext.go @@ -56,7 +56,7 @@ func (ctx *RenderContext) Make(render func(*RenderContext) Component) Node { return root } -func printNodes(node Node, indent int) { +func printNodes(node *Node, indent int) { if len(node.Children) == 0 { fmt.Printf("%s<%T/>\n", strings.Repeat(" ", indent), node.Content) return @@ -64,7 +64,7 @@ func printNodes(node Node, indent int) { fmt.Printf("%s<%T>\n", strings.Repeat(" ", indent), node.Content) for _, child := range node.Children { - printNodes(child, indent+1) + printNodes(&child, indent+1) } fmt.Printf("%s\n", strings.Repeat(" ", indent), node.Content) } @@ -96,16 +96,15 @@ func (ctx *RenderContext) TriggerUpdate() { // fmt.Printf("[%v] RENDER TRIGGERED!\n", ctx) ctx.count = 0 - oldTree := ctx.root // fmt.Println("**** RENDER STARTING ****") newTree := ctx.BuildNode(ctx.content) // fmt.Println("**** RENDER DONE ****") - // fmt.Printf("[%v] Old tree: %+v\n", ctx, oldTree) - // printNodes(oldTree, 0) + // fmt.Printf("[%v] Old tree: %+v\n", ctx, ctx.root) + // printNodes(&ctx.root, 0) // fmt.Printf("[%v] New tree: %+v\n", ctx, newTree) - // printNodes(newTree, 0) + // printNodes(&newTree, 0) - oldTree.Update(newTree, nil) + ctx.root.Update(newTree, nil) }) }