Skip to content

Architecture Overview

Brad Peabody edited this page Jul 20, 2019 · 6 revisions

NOTE: For now, this document applies to the refactor on the component-refactor branch.

  • A BuildEnv keeps track of the components involved in the Build->Render cycle. The cycle starts with a "root" component, on which a Build method is called, passing it a BuildEnv instance. This method returns the virtual DOM corresponding to this root component in its current state, and methods on BuildEnv are used to track the lifecycle of instances of child components.

  • The Builder interface has a single method Build which is implemented by a component and returns it's "virtual DOM" (represented by vugu.VGNode et al)

  • A Renderer is responsible for synchronizing a virtual DOM with its target output. JSRenderer performs synchronization with the browser DOM. Where as StaticHTMLRenderer will output the virtual DOM as a string for use in "server-side rendering", static website output, etc.

  • For something to be a "component" it is only required that it implements the Builder interface. References to child components are done statically in Go code. Likewise in .vugu files references to components correspond directly to package and struct names, there is no "registration" mechanism for components or any concept of components at runtime other than things that implement Builder to generate virtual DOM and use the methods on BuildEnv to manage lifecycle.

  • ParserGo and ParserGoPkg provide the tooling to convert .vugu files or a directory with .vugu files (respectively) into components as described above.

  • Other tools layer on top of the basic ideas above.

You can’t perform that action at this time.