Migrate From v8 to v9
Intro
go-app v9 brings new features like removing the need to manually call compo.Update()
to update what is displayed on the screen. Unfortunately, it comes with some breaking changes.
Changes
This document has for purpose to help you transition from go-app v8 to v9 by enumerating the API changes.
General
- This package now requires Go 1.18
Components
- Components are auto-updated when a component lifecycle event, an HTML event, or a dispatch occurs
Compo.Defer()
has been removed (now in Context)
Context
Context
is now an interfacectx.Src
becomesctx.Src()
ctx.JSSrc
becomesctx.JSSrc()
ctx.AppUpdateAvailable
becomesctx.AppUpdateAvailable()
ctx.Page
becomesctx.Page()
ctx.Dispatch(func())
becomesctx.Dispatch(func(app.Context))
- UI elements are now always checked to be mounted before being dispatched
API design decisions
- V9 release focuses mainly on getting the usage of the package more reactive.
- The API is designed to make unrecommended things difficult. A good example would be calling a
Context.Dispatch()
inside aRender()
method. - With the exception of
Handler
and JS-related things, everything that you might need is now available from Context.