Skip to content

E0338: A hook declared by the constructor ​

Earlier releases let a page's constructor declare its hooks on the embedded ui.Live: p.OnMount((*Page).mount), p.Loads("rows", …), p.OnChange(…). A hook is now declared with an attribute on its method, where it is written, and ui.Live has no such methods. The compiler reports the call with the attribute to write.

Wrong ​

vuka
func NewOrders(db *DB) *Orders {
	o := &Orders{db: db}
	o.OnMount((*Orders).mount)
	o.Loads("rows", (*Orders).loadRows)
	return o
}
vuka
func NewOrders(db *DB) *Orders { return &Orders{db: db} }

@ui.Mount
func (o *Orders) mount(ctx context.Context) error { … }

@ui.Loads("rows")
func (o *Orders) loadRows(ctx context.Context) error { … }

Released under the MIT License. Vuka builds on Go and its tools, which are made by the Go Authors. Vuka is not affiliated with Google or the Go project. Go is a trademark of Google LLC.