nasin/manager.go

34 lines
622 B
Go
Raw Normal View History

package nasin
import "git.tebibyte.media/tomo/tomo"
import "git.tebibyte.media/tomo/tomo/event"
var manager struct {
count int
}
// WaitFor ensures that the application will stay running while the given window
// is open.
func WaitFor (window tomo.Window) event.Cookie {
manager.count ++
isManaged := true
handleClose := func () {
if !isManaged { return }
isManaged = false
manager.count --
if manager.count < 1 {
tomo.Stop()
}
}
2024-09-12 00:42:55 -06:00
handleWaitClose := func () error {
handleClose();
return nil
}
return event.MultiCookie (
window.OnClose(handleClose),
2024-09-12 00:42:55 -06:00
event.FuncCookie(handleWaitClose))
}