Skip to content

Commit

Permalink
[v3] Improve OnShutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
almas1992 committed Jan 10, 2024
1 parent f759162 commit 0c24634
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
8 changes: 2 additions & 6 deletions v3/pkg/application/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,6 @@ type App struct {
// Keybindings
keyBindings map[string]func(window *WebviewWindow)

// OnShutdown is called when the application is about to quit.
// This is useful for cleanup tasks.
// The shutdown process blocks until this function returns
OnShutdown func()
performingShutdown bool
}

Expand Down Expand Up @@ -609,8 +605,8 @@ func (a *App) Quit() {
return
}
a.performingShutdown = true
if a.OnShutdown != nil {
a.OnShutdown()
if a.options.OnShutdown != nil {
a.options.OnShutdown()
}
InvokeSync(func() {
a.windowsLock.RLock()
Expand Down
5 changes: 5 additions & 0 deletions v3/pkg/application/options_application.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ type Options struct {

// KeyBindings is a map of key bindings to functions
KeyBindings map[string]func(window *WebviewWindow)

// OnShutdown is called when the application is about to quit.
// This is useful for cleanup tasks.
// The shutdown process blocks until this function returns
OnShutdown func()
}

// AssetOptions defines the configuration of the AssetServer.
Expand Down

0 comments on commit 0c24634

Please sign in to comment.