app v5.0.1 Release Notes

Release Date: 2019-09-04 // about 1 year ago
  • app

    • 💻 Binding can execute a function on the UI goroutine.
    • Binding can wait for a duration before execution the next function.
    • Message can be emitted from html events.

      func (h *Hello) OnMount() { // Binding to the nameChanged msg that wait 1 second and print logs on// binding an ui gouroutines. app.Bind("nameChanged", h). Wait(time.Second). Do(func() { log.Debug("log from binding goroutine") }). DoOnUI(func() { log.Debug("log from UI goroutine") }). Do(func() { log.Debug("another log from binding goroutine") }) // Binding that is called from an html event and modify the Name field. app.Bind("nameChanged", h). DoOnUI(func(s, e js.Value) { h.Name = s.Get("value").String() app.Render(h) }) }func (h *Hello) Render() string { // Input emit a "nameChanged" message when the onchange event occurs.return \<div\> \<!-- ... --\> \<input value="{{.Name}}" placeholder="What is your name?" onchange={{emit nameChanged}} autofocus\> \<!-- ... --\>\</div\>}