Skip to content

Releases: maxence-charriere/go-app

Event Handler scope

19 Feb 12:06
Compare
Choose a tag to compare

A scope can be added to event handler in order to trigger event handler updates.

In a scenario where we want to remove a element from a list, a solution is to create an EventHandler which got the element id set outside.
The event handler returned will always have the same addr, which prevent the package to define that an update should be done on the given element.

To solve this, a scope has been added to the methods that set EventHandler.
Here is the an example:

type issue499Data struct {
	ID    int
	Value string
}

type issue499 struct {
	app.Compo

	data []issue499Data
}

func newIssue499Data() *issue499 {
	return &issue499{}
}

func (c *issue499) OnMount(app.Context) {
	c.data = []issue499Data{
		{11, "one"},
		{22, "two"},
		{33, "three"},
		{44, "four"},
		{55, "five"},
		{66, "six"},
		{77, "sever"},
		{88, "eight"},
		{99, "nine"},
	}
	c.Update()
}

func (c *issue499) Render() app.UI {
	return app.Div().Body(
		app.H1().Text("Issue 499"),
		app.Div().
			Body(
				app.Range(c.data).Slice(func(i int) app.UI {
					d := c.data[i]
					return app.Button().
						ID(fmt.Sprintf("elem-%v", d.ID)).
						OnClick(c.newListener(d.ID), d.ID). // HERE the element ID is added in order to trigger the handler update since the func pointer returned by newListener is always the same.
						Text(d.Value)
				}),
			),
	)
}

func (c *issue499) newListener(id int) app.EventHandler {
	return func(app.Context, app.Event) {
		for i, d := range c.data {
			if id == d.ID {
				c.data = append(c.data[:i], c.data[i+1:]...)
				c.Update()
				return
			}
		}
	}
}

App resize listener

08 Jan 11:21
Compare
Choose a tag to compare

Hello there,

This release brings a way to be notified that that app window size changed within components. It can be done by implementing the Resizer interface:

type myCompo struct{
    app.Compo
}

func (c *myCompo) OnAppResize(ctx app.Context) {
    // Handle app resizing.
}

It can be quite a handful when building layout components. Shell and Flow has been refactored and now uses this mechanism.

Context app update fix

05 Jan 09:12
Compare
Choose a tag to compare
  • Context in OnMount now correctly reports whether an app update is available.

Blank navigation fix

05 Jan 06:53
db9f244
Compare
Choose a tag to compare

Hello,
Small patch today:

  • Fixed a bug that prevented _bank navigation for paths within the app host
  • Context now have a variable that reports whether the app has been updated in the background

Detect app update

04 Jan 11:30
de538c3
Compare
Choose a tag to compare

Hello there,

This version introduces the Updater interface.
It allows a component to be notified that the app has been updated.

This will allow notifying your users that the app has been updated and modifications are available by reloading the page.

Check the Lifecycle article in the doc to see how to use it.

Improve BrowserStorage + Fixes

29 Dec 14:46
Compare
Choose a tag to compare

Hello,
Here is the changelog:

Documentation & fixes

26 Nov 16:24
0961ba4
Compare
Choose a tag to compare

Hello there.
Big update today since this release introduces a dogfooded documentation for the package:

go-app documentation

Next to this here are the fixes:

  • Iframe attributes have been added
  • Fixed crash when using Javascript function New and Call with interface{}
  • manifest.json has been renamed manifest.webmanifest in order to follow Google PWA guidelines

This release also introduces some experimental widgets that are layout related:

Those widgets are used in the documentation introduced above. Since they are experimental, their API may change.

Bug fixes

25 Aug 05:11
7a55893
Compare
Choose a tag to compare

Hello,

This version provides the following changes:

  • Fixed a bug where boolean attributes were not updated
  • Min() and Max() HTML element functions now take an interface{} argument rather than string

Ads.txt Proxy fixes

12 Aug 11:12
96f2622
Compare
Choose a tag to compare

Hello,

Here is a small release that brings the following:

  • The handler now proxy an ads.txt file that is located at the root of the static files directory. This allows complying with AdSense requirements.
  • app.Input().Step(v int) has been changed to app.Input().Step(v float64) since step can be a decimal value.

Fixes and improvements

11 Jul 14:10
Compare
Choose a tag to compare

Hello,

Here is v7.0.3 which introduces the following changes:

  • Fixed bug that did not remove event handlers when components were dismounted
  • Refactored how scripts are loaded in the Handler by using defer attribute
  • Added Iframe missing attributes
  • Generated GitHub pages are now installable with Chrome
# How to update:
go get -u github.com/maxence-charriere/go-app/v7