Background processing

Background processing that updates the user interface does not require any special thread handling code with Fyne. You can execute the full set of graphical and widget commands in any goroutine—the toolkit will take care of any system thread management.

To add incoming emails to the list in our application, all we need to do is call addEmail() for the new client.EmailMessage and pass that to the list.Prepend() function. The code is as straightforward as the following:

go func() {
for email := range server.Incoming() {
list.Prepend(addEmail(email))
}
}()

That completes our basic GoMail application. Given the Fyne project's similarities to the Shiny toolkit that we explored in Chapter 8Shiny – Experimental Go GUI API, let's also see how we could rebuild the image viewer application.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.141.38.121