github.com/vugu/vugu@v0.3.5/doc.go (about) 1 /* 2 Package vugu provides core functionality including vugu->go codegen and in-browser DOM syncing running in WebAssembly. See http://www.vugu.org/ 3 4 Since Vugu projects can have both client-side (running in WebAssembly) as well as server-side functionality many of the 5 items in this package are available in both environments. Some however are either only available or only generally useful 6 in one environment. 7 8 Common functionality includes the ComponentType interface, and ComponentInst struct corresponding to an instantiated componnet. 9 VGNode and related structs are used to represent a virtual Document Object Model. It is based on golang.org/x/net/html but 10 with additional fields needed for Vugu. Data hashing is performed by ComputeHash() and can be customized by implementing 11 the DataHasher interface. 12 13 Client-side code uses JSEnv to maintain a render loop and regenerate virtual DOM and efficiently synchronize it with 14 the browser as needed. DOMEvent is a wrapper around events from the browser and EventEnv is used to synchronize data 15 access when writing event handler code that spawns goroutines. Where appropriate, server-side stubs are available 16 so components can be compiled for both client (WebAssembly) and server (server-side rendering and testing). 17 18 Server-side code can use ParserGo and ParserGoPkg to parse .vugu files and code generate a corresponding .go file. 19 StaticHTMLEnv can be used to generate static HTML, similar to the output of JSEnv but can be run on the server. 20 Supported features are approximately the same minus event handling, unapplicable to static output. 21 22 */ 23 package vugu 24 25 /* 26 27 old notes: 28 29 Common 30 31 Components and Registration... 32 33 VGNode and friends for virtual DOM: 34 35 <b>Data hashing is perfomed with the ComputeHash() function.<b> <em>It walks your data structure</en> and hashes the information as it goes. 36 It uses xxhash internally and returns a uint64. It is intended to be both fast and have good hash distribution to avoid 37 collision-related bugs. 38 39 someData := &struct{A string}{A:"test"} 40 hv := ComputeHash(someData) 41 42 If the DataHasher interface is implemented by a particular type then ComputeHash will just called it and hash it's return 43 into the calculation. Otherwise ComputeHash walks the data and finds primitive values and hashes them byte by bytes. 44 Nil interfaces and nil pointers are skipped. 45 46 Effective hashing is an important part of achieving good performance in Vugu applications, since the question "is this different 47 than it was before" needs to be asked frequently. The current experiment is to rely entirely on data hashing for change detection 48 rather than implementing a data-binding system. 49 50 */