package ultraviolet import ( "sync" ) type NodeList []*Node type NodeMap map[string]*Node type NodeIds map[string]int type Node struct { mutex sync.Mutex Component Component Children NodeList } func (this *Node) Build(node *Node) { this.mutex.Lock() defer this.mutex.Unlock() this.Component.Clean() this.Children = NodeList{node} for _, child := range this.Children { child.update(this.Component, true) } } func (this *Node) Update() { this.mutex.Lock() defer this.mutex.Unlock() this.update(nil, false) } func (this *Node) update(parent Component, force bool) { if this.Component.Invalidate() || force { this.Component.Build(parent) force = true } for _, child := range this.Children { child.update(this.Component, force) } } func NodeListBuild(list NodeList, nodes ...*Node) NodeList { return append(list, nodes...) }