this will be called by the frontend to say the DOM has been mounted it will eventually send any updated "refs" to the backend as well
()
| 226 | // this will be called by the frontend to say the DOM has been mounted |
| 227 | // it will eventually send any updated "refs" to the backend as well |
| 228 | func (r *RootElem) RunWork() { |
| 229 | workQueue := r.EffectWorkQueue |
| 230 | r.EffectWorkQueue = nil |
| 231 | // first, run effect cleanups |
| 232 | for _, work := range workQueue { |
| 233 | comp := r.CompMap[work.Id] |
| 234 | if comp == nil { |
| 235 | continue |
| 236 | } |
| 237 | hook := comp.Hooks[work.EffectIndex] |
| 238 | if hook.UnmountFn != nil { |
| 239 | hook.UnmountFn() |
| 240 | } |
| 241 | } |
| 242 | // now run, new effects |
| 243 | for _, work := range workQueue { |
| 244 | comp := r.CompMap[work.Id] |
| 245 | if comp == nil { |
| 246 | continue |
| 247 | } |
| 248 | hook := comp.Hooks[work.EffectIndex] |
| 249 | if hook.Fn != nil { |
| 250 | hook.UnmountFn = hook.Fn() |
| 251 | } |
| 252 | } |
| 253 | // now check if we need a render |
| 254 | if len(r.NeedsRenderMap) > 0 { |
| 255 | r.NeedsRenderMap = nil |
| 256 | r.render(r.Root.Elem, &r.Root) |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | func (r *RootElem) render(elem *VDomElem, comp **ComponentImpl) { |
| 261 | if elem == nil || elem.Tag == "" { |