{"id":15705010,"url":"https://github.com/markbates/wailsx","last_synced_at":"2025-10-13T17:05:41.498Z","repository":{"id":224791407,"uuid":"764221197","full_name":"markbates/wailsx","owner":"markbates","description":"WIP: Tools for working with Wails.io","archived":false,"fork":false,"pushed_at":"2024-03-21T22:37:11.000Z","size":274,"stargazers_count":6,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-12T18:08:45.134Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/markbates.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-27T17:37:22.000Z","updated_at":"2024-06-06T00:43:13.000Z","dependencies_parsed_at":"2024-06-21T13:02:22.551Z","dependency_job_id":"5264fa25-316e-4540-baba-185aac5a3369","html_url":"https://github.com/markbates/wailsx","commit_stats":null,"previous_names":["markbates/wailsx"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markbates%2Fwailsx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markbates%2Fwailsx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markbates%2Fwailsx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markbates%2Fwailsx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/markbates","download_url":"https://codeload.github.com/markbates/wailsx/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253795144,"owners_count":21965486,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-03T20:14:34.218Z","updated_at":"2025-10-13T17:05:36.457Z","avatar_url":"https://github.com/markbates.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# \u003ca id=\"heading-0\"\u003e\u003c/a\u003e\u003ctoc-level\u003e1.1\u003c/toc-level\u003e - Wailsx - A Testable, Idiomatic Wrapper for Wails\n\nI love [Wails](https://wails.io) and have been using it to create some great applications. Unfortunately, the Wails `v2` API is not very testable or idiomatic. Wailsx is a wrapper around the Wails API that makes it easier to test and use in a more idiomatic way.\n\n\u003ctoc\u003e\n\n* [\u003ctoc-level\u003e1.1\u003c/toc-level\u003e - Wailsx - A Testable, Idiomatic Wrapper for Wails](#heading-0)\n\n\n* [\u003ctoc-level\u003e1.1.1\u003c/toc-level\u003e - Installation](#heading-1)\n\n* [\u003ctoc-level\u003e1.2\u003c/toc-level\u003e - Runtime and API](#heading-2)\n\n\n* [\u003ctoc-level\u003e1.2.1\u003c/toc-level\u003e - The API Interface](#heading-3)\n\n\n* [\u003ctoc-level\u003e1.2.1.1\u003c/toc-level\u003e - Error Handling](#heading-4)\n\n* [\u003ctoc-level\u003e1.2.2\u003c/toc-level\u003e - Protecting Wails API Calls](#heading-5)\n\n\n* [\u003ctoc-level\u003e1.2.2.2\u003c/toc-level\u003e - Testing Invalid Wails API Calls](#heading-6)\n\n\n* [\u003ctoc-level\u003e1.3\u003c/toc-level\u003e - Clipboard](#heading-7)\n\n\n* [\u003ctoc-level\u003e1.3.1\u003c/toc-level\u003e - The `ClipboardManager` Interface](#heading-8)\n\n* [\u003ctoc-level\u003e1.4\u003c/toc-level\u003e - Dialogs](#heading-9)\n\n\n* [\u003ctoc-level\u003e1.4.1\u003c/toc-level\u003e - The `DialogManager` Interface](#heading-10)\n\n* [\u003ctoc-level\u003e1.5\u003c/toc-level\u003e - Events](#heading-11)\n\n\n* [\u003ctoc-level\u003e1.5.1\u003c/toc-level\u003e - The `EventManager` Interface](#heading-12)\n* [\u003ctoc-level\u003e1.5.2\u003c/toc-level\u003e - The `Manager` Type](#heading-13)\n\n\n* [\u003ctoc-level\u003e1.5.2.1\u003c/toc-level\u003e - Creating a New Manager](#heading-14)\n\n* [\u003ctoc-level\u003e1.5.3\u003c/toc-level\u003e - The `CallbackFn` Type](#heading-15)\n* [\u003ctoc-level\u003e1.5.4\u003c/toc-level\u003e - The `CancelFn` Type](#heading-16)\n\n* [\u003ctoc-level\u003e1.6\u003c/toc-level\u003e - Messages](#heading-17)\n\n\n* [\u003ctoc-level\u003e1.6.1\u003c/toc-level\u003e - The `Messenger` Interface](#heading-18)\n* [\u003ctoc-level\u003e1.6.2\u003c/toc-level\u003e - The `ErrorMessenger` Interface](#heading-19)\n\n* [\u003ctoc-level\u003e1.7\u003c/toc-level\u003e - Logging](#heading-20)\n\n\n* [\u003ctoc-level\u003e1.7.1\u003c/toc-level\u003e - The `WailsLogger` Interface](#heading-21)\n\n* [\u003ctoc-level\u003e1.8\u003c/toc-level\u003e - Menus](#heading-22)\n\n\n* [\u003ctoc-level\u003e1.8.1\u003c/toc-level\u003e - The `MenuManager` Interface](#heading-23)\n\n* [\u003ctoc-level\u003e1.9\u003c/toc-level\u003e - State Data](#heading-24)\n\n\n* [\u003ctoc-level\u003e1.9.1\u003c/toc-level\u003e - The `DataProvider` Interface](#heading-25)\n* [\u003ctoc-level\u003e1.9.2\u003c/toc-level\u003e - The `Data` Interface](#heading-26)\n\n* [\u003ctoc-level\u003e1.10\u003c/toc-level\u003e - Window Management](#heading-27)\n\n\n* [\u003ctoc-level\u003e1.10.1\u003c/toc-level\u003e - The `WindowManager` Interface](#heading-28)\n* [\u003ctoc-level\u003e1.10.2\u003c/toc-level\u003e - The `MaximiseManager` Interface](#heading-29)\n* [\u003ctoc-level\u003e1.10.3\u003c/toc-level\u003e - The `PositionManager` Interface](#heading-30)\n* [\u003ctoc-level\u003e1.10.4\u003c/toc-level\u003e - The `ReloadManager` Interface](#heading-31)\n* [\u003ctoc-level\u003e1.10.5\u003c/toc-level\u003e - The `ThemeManager` Interface](#heading-32)\n* [\u003ctoc-level\u003e1.10.6\u003c/toc-level\u003e - The `Toggler` Interface](#heading-33)\n\n* [\u003ctoc-level\u003e1.11\u003c/toc-level\u003e - Using the API](#heading-34)\n\n\n* [\u003ctoc-level\u003e1.11.1\u003c/toc-level\u003e - The `API` type](#heading-35)\n* [\u003ctoc-level\u003e1.11.2\u003c/toc-level\u003e - `Nil` API Calls](#heading-36)\n* [\u003ctoc-level\u003e1.11.3\u003c/toc-level\u003e - `Nop` API Calls](#heading-37)\n\n\u003c/toc\u003e\n\n## \u003ca id=\"heading-1\"\u003e\u003c/a\u003e\u003ctoc-level\u003e1.1.1\u003c/toc-level\u003e - Installation\n\nWailsx is a Go module and can be installed with `go get`.\n\n\u003ca id=\"figure-1-1\"\u003e\u003c/a\u003e\n\n\n```bash\ngo get github.com/markbates/wailsx\n\n```\n\n\u003e *_Figure 1.1:_ Installing `github.com/markbates/wailsx` with `go get`.*\n\n\nOnce imported, you can use the `wailsx` package in your application.\n\n\u003ca id=\"figure-1-2\"\u003e\u003c/a\u003e\n\n\n```shell\n$ go doc -short github.com/markbates/wailsx.NewAPI\n\nfunc NewAPI() *API\n    NewAPI returns a new API with all the functions, and interfaces, set to\n    their default implementations.\n\n--------------------------------------------------------------------------------\nGo Version: go1.22.1\n\n```\n\n\u003e *_Figure 1.2:_ The [`wailsx.NewAPI`](https://pkg.go.dev/github.com/markbates/wailsx#NewAPI) function*\n\n\n---\n\n# \u003ca id=\"heading-2\"\u003e\u003c/a\u003e\u003ctoc-level\u003e1.2\u003c/toc-level\u003e - Runtime and API\n\n## \u003ca id=\"heading-3\"\u003e\u003c/a\u003e\u003ctoc-level\u003e1.2.1\u003c/toc-level\u003e - The API Interface\n\nThe [`wailsx.API`](https://pkg.go.dev/github.com/markbates/wailsx#API) interface, [Listing 1.1](#listing-1-1) declares an idiomatic interface for the [`github.com/wailsapp/wails/v2/pkg/runtime`](https://pkg.go.dev/github.com/wailsapp/wails/v2/pkg/runtime) package.\n\n\u003ca id=\"listing-1-1\"\u003e\u003c/a\u003e\n\n\n```shell\n$ go doc github.com/markbates/wailsx/wailsrun.API\n\npackage wailsrun // import \"github.com/markbates/wailsx/wailsrun\"\n\ntype API interface {\n\tBrowserOpenURL(ctx context.Context, url string) error\n\tClipboardGetText(ctx context.Context) (string, error)\n\tClipboardSetText(ctx context.Context, text string) error\n\tEventsEmit(ctx context.Context, event string, data ...any) error\n\tEventsOff(ctx context.Context, event string, additional ...string) error\n\tEventsOffAll(ctx context.Context) error\n\tEventsOn(ctx context.Context, event string, callback CallbackFn) (CancelFn, error)\n\tEventsOnMultiple(ctx context.Context, event string, callback CallbackFn, counter int) (CancelFn, error)\n\tEventsOnce(ctx context.Context, event string, callback CallbackFn) (CancelFn, error)\n\tHide(ctx context.Context) error\n\tLogDebug(ctx context.Context, message string) error\n\tLogDebugf(ctx context.Context, format string, args ...any) error\n\tLogError(ctx context.Context, message string) error\n\tLogErrorf(ctx context.Context, format string, args ...any) error\n\tLogFatal(ctx context.Context, message string) error\n\tLogFatalf(ctx context.Context, format string, args ...any) error\n\tLogInfo(ctx context.Context, message string) error\n\tLogInfof(ctx context.Context, format string, args ...any) error\n\tLogPrint(ctx context.Context, message string) error\n\tLogPrintf(ctx context.Context, format string, args ...any) error\n\tLogSetLogLevel(ctx context.Context, level logger.LogLevel) error\n\tLogTrace(ctx context.Context, message string) error\n\tLogTracef(ctx context.Context, format string, args ...any) error\n\tLogWarning(ctx context.Context, message string) error\n\tLogWarningf(ctx context.Context, format string, args ...any) error\n\tMenuSetApplicationMenu(ctx context.Context, menu *menu.Menu) error\n\tMenuUpdateApplicationMenu(ctx context.Context) error\n\tMessageDialog(ctx context.Context, dialogOptions MessageDialogOptions) (string, error)\n\tOpenDirectoryDialog(ctx context.Context, dialogOptions OpenDialogOptions) (string, error)\n\tOpenFileDialog(ctx context.Context, dialogOptions OpenDialogOptions) (string, error)\n\tOpenMultipleFilesDialog(ctx context.Context, dialogOptions OpenDialogOptions) ([]string, error)\n\tQuit(ctx context.Context) error\n\tSaveFileDialog(ctx context.Context, dialogOptions SaveDialogOptions) (string, error)\n\tShow(ctx context.Context) error\n\tWindowCenter(ctx context.Context) error\n\tWindowExecJS(ctx context.Context, js string) error\n\tWindowFullscreen(ctx context.Context) error\n\tWindowGetPosition(ctx context.Context) (int, int, error)\n\tWindowGetSize(ctx context.Context) (int, int, error)\n\tWindowHide(ctx context.Context) error\n\tWindowIsFullscreen(ctx context.Context) (bool, error)\n\tWindowIsMaximised(ctx context.Context) (bool, error)\n\tWindowIsMinimised(ctx context.Context) (bool, error)\n\tWindowIsNormal(ctx context.Context) (bool, error)\n\tWindowMaximise(ctx context.Context) error\n\tWindowMinimise(ctx context.Context) error\n\tWindowPrint(ctx context.Context) error\n\tWindowReload(ctx context.Context) error\n\tWindowReloadApp(ctx context.Context) error\n\tWindowSetAlwaysOnTop(ctx context.Context, b bool) error\n\tWindowSetBackgroundColour(ctx context.Context, R, G, B, A uint8) error\n\tWindowSetDarkTheme(ctx context.Context) error\n\tWindowSetLightTheme(ctx context.Context) error\n\tWindowSetMaxSize(ctx context.Context, width int, height int) error\n\tWindowSetMinSize(ctx context.Context, width int, height int) error\n\tWindowSetPosition(ctx context.Context, x int, y int) error\n\tWindowSetSize(ctx context.Context, width int, height int) error\n\tWindowSetSystemDefaultTheme(ctx context.Context) error\n\tWindowSetTitle(ctx context.Context, title string) error\n\tWindowShow(ctx context.Context) error\n\tWindowToggleMaximise(ctx context.Context) error\n\tWindowUnfullscreen(ctx context.Context) error\n\tWindowUnmaximise(ctx context.Context) error\n\tWindowUnminimise(ctx context.Context) error\n\tScreenGetAll(ctx context.Context) ([]Screen, error)\n}\n\n--------------------------------------------------------------------------------\nGo Version: go1.22.1\n\n```\n\n\u003e *_Listing 1.1:_ The [`wailsx.API`](https://pkg.go.dev/github.com/markbates/wailsx#API) interface*\n\n\n### \u003ca id=\"heading-4\"\u003e\u003c/a\u003e\u003ctoc-level\u003e1.2.1.1\u003c/toc-level\u003e - Error Handling\n\nIn particular, the [`wailsx.API`](https://pkg.go.dev/github.com/markbates/wailsx#API) improves error handling by adding error returns to the methods that previously returned nothing. For example, the [`runtime.MenuSetApplicationMenu`](https://pkg.go.dev/github.com/wailsapp/wails/v2/pkg/runtime#MenuSetApplicationMenu), [Listing 1.2](#listing-1-2), method now returns an error, [Listing 1.3](#listing-1-3).\n\n\u003ca id=\"listing-1-2\"\u003e\u003c/a\u003e\n\n\n```shell\n$ go doc github.com/wailsapp/wails/v2/pkg/runtime.MenuSetApplicationMenu\n\npackage runtime // import \"github.com/wailsapp/wails/v2/pkg/runtime\"\n\nfunc MenuSetApplicationMenu(ctx context.Context, menu *menu.Menu)\n\n--------------------------------------------------------------------------------\nGo Version: go1.22.1\n\n```\n\n\u003e *_Listing 1.2:_ The [`runtime.MenuSetApplicationMenu`](https://pkg.go.dev/github.com/wailsapp/wails/v2/pkg/runtime#MenuSetApplicationMenu) method*\n\n\n\u003ca id=\"listing-1-3\"\u003e\u003c/a\u003e\n\n\n```shell\n$ go doc github.com/markbates/wailsx/wailsrun.API.MenuSetApplicationMenu\n\npackage wailsrun // import \"github.com/markbates/wailsx/wailsrun\"\n\ntype API interface {\n\tMenuSetApplicationMenu(ctx context.Context, menu *menu.Menu) error\n}\n\n--------------------------------------------------------------------------------\nGo Version: go1.22.1\n\n```\n\n\u003e *_Listing 1.3:_ The [`wailsrun.API.MenuSetApplicationMenu`](https://pkg.go.dev/github.com/markbates/wailsx/wailsrun#API.MenuSetApplicationMenu) method*\n\n\n## \u003ca id=\"heading-5\"\u003e\u003c/a\u003e\u003ctoc-level\u003e1.2.2\u003c/toc-level\u003e - Protecting Wails API Calls\n\nWailsx uses Go build tags to protect the Wails API calls from being called in a production environment. The [`wailsrun.API`](https://pkg.go.dev/github.com/markbates/wailsx/wailsrun#API) interface, [Listing 1.1](#listing-1-1), is implemented in two different files, [Listing 1.4](#listing-1-4) and [Listing 1.5](#listing-1-5).\n\nThe `wailsrun/wailscalls_prod.go` file, [Listing 1.4](#listing-1-4), is only built when any of the following builds are provided: `wails || dev || desktop || production`. This file contains the actual Wails API calls and most returned errors are `nil`.\n\n\u003ca id=\"listing-1-4\"\u003e\u003c/a\u003e\n\n\n```go\nimport (\n\t\"context\"\n\n\t\"github.com/wailsapp/wails/v2/pkg/logger\"\n\t\"github.com/wailsapp/wails/v2/pkg/menu\"\n\t\"github.com/wailsapp/wails/v2/pkg/runtime\"\n)\n\nfunc BrowserOpenURL(ctx context.Context, url string) error {\n\truntime.BrowserOpenURL(ctx, url)\n\treturn nil\n}\n```\n\u003e *source: wailsrun/wailscalls_prod.go:BrowserOpenURL*\n\n\n\u003e *_Listing 1.4:_ Production Wails API calls: `wailsrun/wailscalls_prod.go`*\n\n\nIn all other environments, such as testing, the `wailsrun/wailscalls.go` file, [Listing 1.5](#listing-1-5), is built in all environments and contains the Wailsx API calls. The Wailsx API calls are then used to call the Wails API calls in the `development` environment.\n\n\u003ca id=\"listing-1-5\"\u003e\u003c/a\u003e\n\n\n```go\nimport (\n\t\"context\"\n\n\t\"github.com/wailsapp/wails/v2/pkg/logger\"\n\t\"github.com/wailsapp/wails/v2/pkg/menu\"\n)\n\nfunc BrowserOpenURL(ctx context.Context, url string) error {\n\treturn ErrNotAvailable(\"BrowserOpenURL\")\n}\n```\n\u003e *source: wailsrun/wailscalls.go:BrowserOpenURL*\n\n\n\u003e *_Listing 1.5:_ Stubbed Wails API calls: `wailsrun/wailscalls.go`*\n\n\nIn these environments all of the Wails API calls will return the `ErrNotAvailable` error, [Listing 1.6](#listing-1-6).\n\n\u003ca id=\"listing-1-6\"\u003e\u003c/a\u003e\n\n\n```shell\n$ go doc github.com/markbates/wailsx/wailsrun.ErrNotAvailable\n\npackage wailsrun // import \"github.com/markbates/wailsx/wailsrun\"\n\ntype ErrNotAvailable string\n\nfunc (e ErrNotAvailable) Error() string\n\n--------------------------------------------------------------------------------\nGo Version: go1.22.1\n\n```\n\n\u003e *_Listing 1.6:_ The [`wailsrun.ErrNotAvailable`](https://pkg.go.dev/github.com/markbates/wailsx/wailsrun#ErrNotAvailable) error*\n\n\n### \u003ca id=\"heading-6\"\u003e\u003c/a\u003e\u003ctoc-level\u003e1.2.2.2\u003c/toc-level\u003e - Testing Invalid Wails API Calls\n\nWith the help of Go build tags, any direct calls made to the Wails API, _outside_ of a running Wails application, will return the [`wailsrun.ErrNotAvailable`](https://pkg.go.dev/github.com/markbates/wailsx/wailsrun#ErrNotAvailable) error. This allows for testing of the Wails API calls in a non-Wails environment.\n\nIn the test seen in [Listing 1.7](#listing-1-7) we are making a direct call to the Wails API and checking the error returned. The test passes when the error returned is `ErrNotAvailable`.\n\n\u003ca id=\"listing-1-7\"\u003e\u003c/a\u003e\n\n\n```go\nfunc Test_ErrNotAvailable(t *testing.T) {\n\tt.Parallel()\n\n\tr := require.New(t)\n\n\tctx := context.Background()\n\n\terr := wailsrun.BrowserOpenURL(ctx, \"https://example.com\")\n\tr.Error(err)\n\n\texp := wailsrun.ErrNotAvailable(\"BrowserOpenURL\")\n\tr.Equal(exp, err)\n}\n```\n\u003e *source: wailsrun/api_calls_test.go:err-not-available*\n\n\n\u003e *_Listing 1.7:_ Testing the [`wailsrun.ErrNotAvailable`](https://pkg.go.dev/github.com/markbates/wailsx/wailsrun#ErrNotAvailable) method*\n\n\nWhen running the tests outside of a Wails application, the [`wailsrun.ErrNotAvailable`](https://pkg.go.dev/github.com/markbates/wailsx/wailsrun#ErrNotAvailable) method will return the `ErrNotAvailable` error, [Listing 1.6](#listing-1-6).\n\n\u003ca id=\"listing-1-8\"\u003e\u003c/a\u003e\n\n\n```shell\n$ go test -v -run Test_ErrNotAvailable\n\ntesting: warning: no tests to run\nPASS\nok  \tgithub.com/markbates/wailsx\t0.006s\n\ngo: downloading github.com/markbates/safe v1.1.0\ngo: downloading github.com/wailsapp/wails/v2 v2.8.0\ngo: downloading github.com/stretchr/testify v1.9.0\ngo: downloading github.com/davecgh/go-spew v1.1.1\ngo: downloading github.com/pmezard/go-difflib v1.0.0\ngo: downloading gopkg.in/yaml.v3 v3.0.1\ngo: downloading github.com/leaanthony/slicer v1.6.0\ngo: downloading github.com/leaanthony/u v1.1.1\n\n--------------------------------------------------------------------------------\nGo Version: go1.22.1\n\n```\n\n\u003e *_Listing 1.8:_ Testing the [`wailsrun.ErrNotAvailable`](https://pkg.go.dev/github.com/markbates/wailsx/wailsrun#ErrNotAvailable) method output.*\n\n\nIf the tests are run in a Wails application, using one of the known build tags, the [`wailsrun.ErrNotAvailable`](https://pkg.go.dev/github.com/markbates/wailsx/wailsrun#ErrNotAvailable) method will call the actual Wails API method, [Listing 1.4](#listing-1-4). The result is a call to [`log.Fatal`](https://pkg.go.dev/log#Fatal) because we don't have a valid Wails context.\n\n\u003ca id=\"listing-1-9\"\u003e\u003c/a\u003e\n\n\n```shell\n$ go test -v -run Test_ErrNotAvailable -tags wails\n\ntesting: warning: no tests to run\nPASS\nok  \tgithub.com/markbates/wailsx\t0.003s\n\ngo: downloading github.com/markbates/safe v1.1.0\ngo: downloading github.com/wailsapp/wails/v2 v2.8.0\ngo: downloading github.com/stretchr/testify v1.9.0\ngo: downloading github.com/davecgh/go-spew v1.1.1\ngo: downloading github.com/pmezard/go-difflib v1.0.0\ngo: downloading gopkg.in/yaml.v3 v3.0.1\ngo: downloading github.com/leaanthony/slicer v1.6.0\ngo: downloading github.com/leaanthony/u v1.1.1\n\n--------------------------------------------------------------------------------\nGo Version: go1.22.1\n\n```\n\n\u003e *_Listing 1.9:_ Testing the [`wailsrun.ErrNotAvailable`](https://pkg.go.dev/github.com/markbates/wailsx/wailsrun#ErrNotAvailable) method output in `production`.*\n\n\n---\n\n# \u003ca id=\"heading-7\"\u003e\u003c/a\u003e\u003ctoc-level\u003e1.3\u003c/toc-level\u003e - Clipboard\n\n## \u003ca id=\"heading-8\"\u003e\u003c/a\u003e\u003ctoc-level\u003e1.3.1\u003c/toc-level\u003e - The \u003ccode\u003eClipboardManager\u003c/code\u003e Interface\n\n\u003ca id=\"figure-1-3\"\u003e\u003c/a\u003e\n\n\n```shell\n$ go doc github.com/markbates/wailsx/clipx.ClipboardManager\n\npackage clipx // import \"github.com/markbates/wailsx/clipx\"\n\ntype ClipboardManager interface {\n\tClipboardGetText(ctx context.Context) (string, error)\n\tClipboardSetText(ctx context.Context, text string) error\n}\n\n--------------------------------------------------------------------------------\nGo Version: go1.22.1\n\n```\n\n\u003e *_Figure 1.3:_ The [`clipx.ClipboardManager`](https://pkg.go.dev/github.com/markbates/wailsx/clipx#ClipboardManager) interface*\n\n\n---\n\n# \u003ca id=\"heading-9\"\u003e\u003c/a\u003e\u003ctoc-level\u003e1.4\u003c/toc-level\u003e - Dialogs\n\n## \u003ca id=\"heading-10\"\u003e\u003c/a\u003e\u003ctoc-level\u003e1.4.1\u003c/toc-level\u003e - The \u003ccode\u003eDialogManager\u003c/code\u003e Interface\n\n\u003ca id=\"listing-1-10\"\u003e\u003c/a\u003e\n\n\n```shell\n$ go doc github.com/markbates/wailsx/dialogx.DialogManager\n\npackage dialogx // import \"github.com/markbates/wailsx/dialogx\"\n\ntype DialogManager interface {\n\tMessageDialog(ctx context.Context, opts MessageDialogOptions) (string, error)\n\tOpenDirectoryDialog(ctx context.Context, opts OpenDialogOptions) (string, error)\n\tOpenFileDialog(ctx context.Context, opts OpenDialogOptions) (string, error)\n\tOpenMultipleFilesDialog(ctx context.Context, opts OpenDialogOptions) ([]string, error)\n\tSaveFileDialog(ctx context.Context, opts SaveDialogOptions) (string, error)\n}\n\n--------------------------------------------------------------------------------\nGo Version: go1.22.1\n\n```\n\n\u003e *_Listing 1.10:_ The [`dialogx.DialogManager`](https://pkg.go.dev/github.com/markbates/wailsx/dialogx#DialogManager) interface*\n\n\n---\n\n# \u003ca id=\"heading-11\"\u003e\u003c/a\u003e\u003ctoc-level\u003e1.5\u003c/toc-level\u003e - Events\n\n## \u003ca id=\"heading-12\"\u003e\u003c/a\u003e\u003ctoc-level\u003e1.5.1\u003c/toc-level\u003e - The \u003ccode\u003eEventManager\u003c/code\u003e Interface\n\n\u003ca id=\"listing-1-11\"\u003e\u003c/a\u003e\n\n\n```shell\n$ go doc github.com/markbates/wailsx/eventx.EventManager\n\npackage eventx // import \"github.com/markbates/wailsx/eventx\"\n\ntype EventManager interface {\n\tEventsEmit(ctx context.Context, event string, args ...any) (err error)\n\tEventsOff(ctx context.Context, name string, additional ...string) error\n\tEventsOffAll(ctx context.Context) error\n\tEventsOn(ctx context.Context, name string, callback CallbackFn) (CancelFn, error)\n\tEventsOnMultiple(ctx context.Context, name string, callback CallbackFn, counter int) (CancelFn, error)\n\tEventsOnce(ctx context.Context, name string, callback CallbackFn) (CancelFn, error)\n}\n\n--------------------------------------------------------------------------------\nGo Version: go1.22.1\n\n```\n\n\u003e *_Listing 1.11:_ The [`eventx.EventManager`](https://pkg.go.dev/github.com/markbates/wailsx/eventx#EventManager) interface*\n\n\n## \u003ca id=\"heading-13\"\u003e\u003c/a\u003e\u003ctoc-level\u003e1.5.2\u003c/toc-level\u003e - The \u003ccode\u003eManager\u003c/code\u003e Type\n\n\u003ca id=\"listing-1-12\"\u003e\u003c/a\u003e\n\n\n```shell\n$ go doc github.com/markbates/wailsx/eventx.Manager\n\npackage eventx // import \"github.com/markbates/wailsx/eventx\"\n\ntype Manager struct {\n\tDisableWildcardEmits bool\n\tDisableStateData     bool\n\n\tEventsEmitFn       func(ctx context.Context, name string, data ...any) error\n\tEventsOffAllFn     func(ctx context.Context) error\n\tEventsOffFn        func(ctx context.Context, name string, additional ...string) error\n\tEventsOnFn         func(ctx context.Context, name string, callback CallbackFn) (CancelFn, error)\n\tEventsOnMultipleFn func(ctx context.Context, name string, callback CallbackFn, counter int) (CancelFn, error)\n\tEventsOnceFn       func(ctx context.Context, name string, callback CallbackFn) (CancelFn, error)\n\n\tNowFn func() time.Time\n\n\t// Has unexported fields.\n}\n\nfunc NewManager() *Manager\nfunc NopManager() *Manager\nfunc (em *Manager) EventsEmit(ctx context.Context, event string, args ...any) (err error)\nfunc (em *Manager) EventsOff(ctx context.Context, name string, additional ...string) error\nfunc (em *Manager) EventsOffAll(ctx context.Context) error\nfunc (em *Manager) EventsOn(ctx context.Context, name string, callback CallbackFn) (CancelFn, error)\nfunc (em *Manager) EventsOnMultiple(ctx context.Context, name string, callback CallbackFn, counter int) (CancelFn, error)\nfunc (em *Manager) EventsOnce(ctx context.Context, name string, callback CallbackFn) (CancelFn, error)\nfunc (em *Manager) MarshalJSON() ([]byte, error)\nfunc (em *Manager) Now() time.Time\nfunc (em *Manager) PluginName() string\nfunc (em *Manager) StateData(ctx context.Context) (statedata.Data[*EventsData], error)\nfunc (em *Manager) WithPlugins(fn plugins.FeederFn) error\n\n--------------------------------------------------------------------------------\nGo Version: go1.22.1\n\n```\n\n\u003e *_Listing 1.12:_ The [`eventx.Manager`](https://pkg.go.dev/github.com/markbates/wailsx/eventx#Manager) type*\n\n\n### \u003ca id=\"heading-14\"\u003e\u003c/a\u003e\u003ctoc-level\u003e1.5.2.1\u003c/toc-level\u003e - Creating a New Manager\n\n\u003ca id=\"listing-1-13\"\u003e\u003c/a\u003e\n\n\n```shell\n$ go doc github.com/markbates/wailsx/eventx.NewManager\n\npackage eventx // import \"github.com/markbates/wailsx/eventx\"\n\nfunc NewManager() *Manager\n\n--------------------------------------------------------------------------------\nGo Version: go1.22.1\n\n```\n\n\u003e *_Listing 1.13:_ The [`eventx.NewManager`](https://pkg.go.dev/github.com/markbates/wailsx/eventx#NewManager) function*\n\n\n\u003ca id=\"listing-1-14\"\u003e\u003c/a\u003e\n\n\n```shell\n$ go doc github.com/markbates/wailsx/eventx.NopManager\n\npackage eventx // import \"github.com/markbates/wailsx/eventx\"\n\nfunc NopManager() *Manager\n    NopManager returns a new Manager with all the functions set to no-ops This\n    is useful for testing. The NowFn is set to wailstest.NowTime\n\n--------------------------------------------------------------------------------\nGo Version: go1.22.1\n\n```\n\n\u003e *_Listing 1.14:_ The [`eventx.NopManager`](https://pkg.go.dev/github.com/markbates/wailsx/eventx#NopManager) function*\n\n\n## \u003ca id=\"heading-15\"\u003e\u003c/a\u003e\u003ctoc-level\u003e1.5.3\u003c/toc-level\u003e - The \u003ccode\u003eCallbackFn\u003c/code\u003e Type\n\n\u003ca id=\"listing-1-15\"\u003e\u003c/a\u003e\n\n\n```shell\n$ go doc github.com/markbates/wailsx/wailsrun.CallbackFn\n\npackage wailsrun // import \"github.com/markbates/wailsx/wailsrun\"\n\ntype CallbackFn func(data ...any) error\n\n--------------------------------------------------------------------------------\nGo Version: go1.22.1\n\n```\n\n\u003e *_Listing 1.15:_ The [`eventx.CallbackFn`](https://pkg.go.dev/github.com/markbates/wailsx/eventx#CallbackFn) type*\n\n\n## \u003ca id=\"heading-16\"\u003e\u003c/a\u003e\u003ctoc-level\u003e1.5.4\u003c/toc-level\u003e - The \u003ccode\u003eCancelFn\u003c/code\u003e Type\n\n\u003ca id=\"listing-1-16\"\u003e\u003c/a\u003e\n\n\n```shell\n$ go doc github.com/markbates/wailsx/wailsrun.CancelFn\n\npackage wailsrun // import \"github.com/markbates/wailsx/wailsrun\"\n\ntype CancelFn func() error\n\nfunc EventsOn(ctx context.Context, event string, callback CallbackFn) (CancelFn, error)\nfunc EventsOnMultiple(ctx context.Context, event string, callback CallbackFn, counter int) (CancelFn, error)\nfunc EventsOnce(ctx context.Context, event string, callback CallbackFn) (CancelFn, error)\n\n--------------------------------------------------------------------------------\nGo Version: go1.22.1\n\n```\n\n\u003e *_Listing 1.16:_ The [`eventx.CancelFn`](https://pkg.go.dev/github.com/markbates/wailsx/eventx#CancelFn) type*\n\n\n---\n\n# \u003ca id=\"heading-17\"\u003e\u003c/a\u003e\u003ctoc-level\u003e1.6\u003c/toc-level\u003e - Messages\n\n## \u003ca id=\"heading-18\"\u003e\u003c/a\u003e\u003ctoc-level\u003e1.6.1\u003c/toc-level\u003e - The \u003ccode\u003eMessenger\u003c/code\u003e Interface\n\n\u003ca id=\"listing-1-17\"\u003e\u003c/a\u003e\n\n\n```shell\n$ go doc github.com/markbates/wailsx/eventx/msgx.Messenger\n\npackage msgx // import \"github.com/markbates/wailsx/eventx/msgx\"\n\ntype Messenger interface {\n\tMsgEvent() string\n\tMsgText() string\n\tMsgTime() time.Time\n\tMsgData() any\n}\n\nfunc NewMessage(event string, now time.Time, arg any) Messenger\n\n--------------------------------------------------------------------------------\nGo Version: go1.22.1\n\n```\n\n\u003e *_Listing 1.17:_ The [`msgx.Messenger`](https://pkg.go.dev/github.com/markbates/wailsx/eventx/msgx#Messenger) interface*\n\n\n## \u003ca id=\"heading-19\"\u003e\u003c/a\u003e\u003ctoc-level\u003e1.6.2\u003c/toc-level\u003e - The \u003ccode\u003eErrorMessenger\u003c/code\u003e Interface\n\n\u003ca id=\"listing-1-18\"\u003e\u003c/a\u003e\n\n\n```shell\n$ go doc github.com/markbates/wailsx/eventx/msgx.ErrorMessenger\n\npackage msgx // import \"github.com/markbates/wailsx/eventx/msgx\"\n\ntype ErrorMessenger interface {\n\tMessenger\n\tMsgError() error\n}\n\n--------------------------------------------------------------------------------\nGo Version: go1.22.1\n\n```\n\n\u003e *_Listing 1.18:_ The [`msgx.ErrorMessenger`](https://pkg.go.dev/github.com/markbates/wailsx/eventx/msgx#ErrorMessenger) interface*\n\n\n---\n\n# \u003ca id=\"heading-20\"\u003e\u003c/a\u003e\u003ctoc-level\u003e1.7\u003c/toc-level\u003e - Logging\n\n## \u003ca id=\"heading-21\"\u003e\u003c/a\u003e\u003ctoc-level\u003e1.7.1\u003c/toc-level\u003e - The \u003ccode\u003eWailsLogger\u003c/code\u003e Interface\n\n\u003ca id=\"listing-1-19\"\u003e\u003c/a\u003e\n\n\n```shell\n$ go doc github.com/markbates/wailsx/logx.WailsLogger\n\npackage logx // import \"github.com/markbates/wailsx/logx\"\n\ntype WailsLogger interface {\n\tLogDebug(ctx context.Context, message string) error\n\tLogDebugf(ctx context.Context, format string, args ...any) error\n\tLogError(ctx context.Context, message string) error\n\tLogErrorf(ctx context.Context, format string, args ...any) error\n\tLogFatal(ctx context.Context, message string) error\n\tLogFatalf(ctx context.Context, format string, args ...any) error\n\tLogInfo(ctx context.Context, message string) error\n\tLogInfof(ctx context.Context, format string, args ...any) error\n\tLogPrint(ctx context.Context, message string) error\n\tLogPrintf(ctx context.Context, format string, args ...any) error\n\tLogSetLogLevel(ctx context.Context, level wailsrun.LogLevel) error\n\tLogTrace(ctx context.Context, message string) error\n\tLogTracef(ctx context.Context, format string, args ...any) error\n\tLogWarning(ctx context.Context, message string) error\n\tLogWarningf(ctx context.Context, format string, args ...any) error\n}\n\n--------------------------------------------------------------------------------\nGo Version: go1.22.1\n\n```\n\n\u003e *_Listing 1.19:_ The [`logx.WailsLogger`](https://pkg.go.dev/github.com/markbates/wailsx/logx#WailsLogger) interface*\n\n\n---\n\n# \u003ca id=\"heading-22\"\u003e\u003c/a\u003e\u003ctoc-level\u003e1.8\u003c/toc-level\u003e - Menus\n\n## \u003ca id=\"heading-23\"\u003e\u003c/a\u003e\u003ctoc-level\u003e1.8.1\u003c/toc-level\u003e - The \u003ccode\u003eMenuManager\u003c/code\u003e Interface\n\n\u003ca id=\"listing-1-20\"\u003e\u003c/a\u003e\n\n\n```shell\n$ go doc github.com/markbates/wailsx/menux.MenuManager\n\npackage menux // import \"github.com/markbates/wailsx/menux\"\n\ntype MenuManager interface {\n\tMenuSetApplicationMenu(ctx context.Context, menu *menu.Menu) error\n\tMenuUpdateApplicationMenu(ctx context.Context) error\n}\n\n--------------------------------------------------------------------------------\nGo Version: go1.22.1\n\n```\n\n\u003e *_Listing 1.20:_ The [`menux.MenuManager`](https://pkg.go.dev/github.com/markbates/wailsx/menux#MenuManager) interface*\n\n\n---\n\n# \u003ca id=\"heading-24\"\u003e\u003c/a\u003e\u003ctoc-level\u003e1.9\u003c/toc-level\u003e - State Data\n\n## \u003ca id=\"heading-25\"\u003e\u003c/a\u003e\u003ctoc-level\u003e1.9.1\u003c/toc-level\u003e - The \u003ccode\u003eDataProvider\u003c/code\u003e Interface\n\n\u003ca id=\"listing-1-21\"\u003e\u003c/a\u003e\n\n\n```shell\n$ go doc github.com/markbates/wailsx/statedata.DataProvider\n\npackage statedata // import \"github.com/markbates/wailsx/statedata\"\n\ntype DataProvider[T any] interface {\n\tStateData(ctx context.Context) (Data[T], error)\n}\n\n--------------------------------------------------------------------------------\nGo Version: go1.22.1\n\n```\n\n\u003e *_Listing 1.21:_ The [`statedata.DataProvider`](https://pkg.go.dev/github.com/markbates/wailsx/statedata#DataProvider) interface*\n\n\n## \u003ca id=\"heading-26\"\u003e\u003c/a\u003e\u003ctoc-level\u003e1.9.2\u003c/toc-level\u003e - The \u003ccode\u003eData\u003c/code\u003e Interface\n\n\u003ca id=\"listing-1-22\"\u003e\u003c/a\u003e\n\n\n```shell\n$ go doc github.com/markbates/wailsx/statedata.Data\n\npackage statedata // import \"github.com/markbates/wailsx/statedata\"\n\ntype Data[T any] struct {\n\tName string `json:\"name,omitempty\"` // name of the data\n\tData T      `json:\"data,omitempty\"` // data for the state\n}\n\nfunc (sd Data[T]) PluginName() string\nfunc (sd Data[T]) StateData(ctx context.Context) (Data[T], error)\n\n--------------------------------------------------------------------------------\nGo Version: go1.22.1\n\n```\n\n\u003e *_Listing 1.22:_ The [`statedata.Data`](https://pkg.go.dev/github.com/markbates/wailsx/statedata#Data) interface*\n\n\n---\n\n# \u003ca id=\"heading-27\"\u003e\u003c/a\u003e\u003ctoc-level\u003e1.10\u003c/toc-level\u003e - Window Management\n\n## \u003ca id=\"heading-28\"\u003e\u003c/a\u003e\u003ctoc-level\u003e1.10.1\u003c/toc-level\u003e - The \u003ccode\u003eWindowManager\u003c/code\u003e Interface\n\n\u003ca id=\"listing-1-23\"\u003e\u003c/a\u003e\n\n\n```shell\n$ go doc github.com/markbates/wailsx/windowx.WindowManager\n\npackage windowx // import \"github.com/markbates/wailsx/windowx\"\n\ntype WindowManager interface {\n\tMaximiseManager\n\tPositionManager\n\tReloadManager\n\tThemeManager\n\tToggler\n\n\tScreenGetAll(ctx context.Context) ([]Screen, error)\n\tWindowExecJS(ctx context.Context, js string) error\n\tWindowPrint(ctx context.Context) error\n\tWindowSetAlwaysOnTop(ctx context.Context, b bool) error\n\tWindowSetTitle(ctx context.Context, title string) error\n}\n\n--------------------------------------------------------------------------------\nGo Version: go1.22.1\n\n```\n\n\u003e *_Listing 1.23:_ The [`windowx.WindowManager`](https://pkg.go.dev/github.com/markbates/wailsx/windowx#WindowManager) interface*\n\n\n## \u003ca id=\"heading-29\"\u003e\u003c/a\u003e\u003ctoc-level\u003e1.10.2\u003c/toc-level\u003e - The \u003ccode\u003eMaximiseManager\u003c/code\u003e Interface\n\n\u003ca id=\"listing-1-24\"\u003e\u003c/a\u003e\n\n\n```shell\n$ go doc github.com/markbates/wailsx/windowx.MaximiseManager\n\npackage windowx // import \"github.com/markbates/wailsx/windowx\"\n\ntype MaximiseManager interface {\n\tWindowFullscreen(ctx context.Context) error\n\tWindowIsFullscreen(ctx context.Context) (bool, error)\n\tWindowIsMaximised(ctx context.Context) (bool, error)\n\tWindowIsMinimised(ctx context.Context) (bool, error)\n\tWindowIsNormal(ctx context.Context) (bool, error)\n\tWindowMaximise(ctx context.Context) error\n\tWindowMinimise(ctx context.Context) error\n\tWindowToggleMaximise(ctx context.Context) error\n\tWindowUnfullscreen(ctx context.Context) error\n\tWindowUnmaximise(ctx context.Context) error\n\tWindowUnminimise(ctx context.Context) error\n}\n\n--------------------------------------------------------------------------------\nGo Version: go1.22.1\n\n```\n\n\u003e *_Listing 1.24:_ The [`windowx.MaximiseManager`](https://pkg.go.dev/github.com/markbates/wailsx/windowx#MaximiseManager) interface*\n\n\n## \u003ca id=\"heading-30\"\u003e\u003c/a\u003e\u003ctoc-level\u003e1.10.3\u003c/toc-level\u003e - The \u003ccode\u003ePositionManager\u003c/code\u003e Interface\n\n\u003ca id=\"listing-1-25\"\u003e\u003c/a\u003e\n\n\n```shell\n$ go doc github.com/markbates/wailsx/windowx.PositionManager\n\npackage windowx // import \"github.com/markbates/wailsx/windowx\"\n\ntype PositionManager interface {\n\tWindowCenter(ctx context.Context) error\n\tWindowGetPosition(ctx context.Context) (int, int, error)\n\tWindowGetSize(ctx context.Context) (int, int, error)\n\tWindowSetMaxSize(ctx context.Context, width int, height int) error\n\tWindowSetMinSize(ctx context.Context, width int, height int) error\n\tWindowSetPosition(ctx context.Context, x int, y int) error\n\tWindowSetSize(ctx context.Context, width int, height int) error\n}\n\n--------------------------------------------------------------------------------\nGo Version: go1.22.1\n\n```\n\n\u003e *_Listing 1.25:_ The [`windowx.PositionManager`](https://pkg.go.dev/github.com/markbates/wailsx/windowx#PositionManager) interface*\n\n\n## \u003ca id=\"heading-31\"\u003e\u003c/a\u003e\u003ctoc-level\u003e1.10.4\u003c/toc-level\u003e - The \u003ccode\u003eReloadManager\u003c/code\u003e Interface\n\n\u003ca id=\"listing-1-26\"\u003e\u003c/a\u003e\n\n\n```shell\n$ go doc github.com/markbates/wailsx/windowx.ReloadManager\n\npackage windowx // import \"github.com/markbates/wailsx/windowx\"\n\ntype ReloadManager interface {\n\tWindowReload(ctx context.Context) error\n\tWindowReloadApp(ctx context.Context) error\n}\n\n--------------------------------------------------------------------------------\nGo Version: go1.22.1\n\n```\n\n\u003e *_Listing 1.26:_ The [`windowx.ReloadManager`](https://pkg.go.dev/github.com/markbates/wailsx/windowx#ReloadManager) interface*\n\n\n## \u003ca id=\"heading-32\"\u003e\u003c/a\u003e\u003ctoc-level\u003e1.10.5\u003c/toc-level\u003e - The \u003ccode\u003eThemeManager\u003c/code\u003e Interface\n\n\u003ca id=\"listing-1-27\"\u003e\u003c/a\u003e\n\n\n```shell\n$ go doc github.com/markbates/wailsx/windowx.ThemeManager\n\npackage windowx // import \"github.com/markbates/wailsx/windowx\"\n\ntype ThemeManager interface {\n\tWindowSetBackgroundColour(ctx context.Context, R, G, B, A uint8) error\n\tWindowSetDarkTheme(ctx context.Context) error\n\tWindowSetLightTheme(ctx context.Context) error\n\tWindowSetSystemDefaultTheme(ctx context.Context) error\n}\n\n--------------------------------------------------------------------------------\nGo Version: go1.22.1\n\n```\n\n\u003e *_Listing 1.27:_ The [`windowx.ThemeManager`](https://pkg.go.dev/github.com/markbates/wailsx/windowx#ThemeManager) interface*\n\n\n## \u003ca id=\"heading-33\"\u003e\u003c/a\u003e\u003ctoc-level\u003e1.10.6\u003c/toc-level\u003e - The \u003ccode\u003eToggler\u003c/code\u003e Interface\n\n\u003ca id=\"listing-1-28\"\u003e\u003c/a\u003e\n\n\n```shell\n$ go doc github.com/markbates/wailsx/windowx.Toggler\n\npackage windowx // import \"github.com/markbates/wailsx/windowx\"\n\ntype Toggler interface {\n\tHide(ctx context.Context) error\n\tShow(ctx context.Context) error\n\tWindowHide(ctx context.Context) error\n\tWindowShow(ctx context.Context) error\n}\n\n--------------------------------------------------------------------------------\nGo Version: go1.22.1\n\n```\n\n\u003e *_Listing 1.28:_ The [`windowx.Toggler`](https://pkg.go.dev/github.com/markbates/wailsx/windowx#Toggler) interface*\n\n\n---\n\n# \u003ca id=\"heading-34\"\u003e\u003c/a\u003e\u003ctoc-level\u003e1.11\u003c/toc-level\u003e - Using the API\n\nWhile the [`github.com/markbates/wailsx/wailsrun`](https://pkg.go.dev/github.com/markbates/wailsx/wailsrun) package can be used directly, it is recommended to use the [`github.com/markbates/wailsx.API`](https://pkg.go.dev/github.com/markbates/wailsx.API) type to create a testable, idiomatic wrapper around the Wails API.\n\n## \u003ca id=\"heading-35\"\u003e\u003c/a\u003e\u003ctoc-level\u003e1.11.1\u003c/toc-level\u003e - The \u003ccode\u003eAPI\u003c/code\u003e type\n\nThe [`wailsx.API`](https://pkg.go.dev/github.com/markbates/wailsx#API) type is a wrapper around the [`github.com/markbates/wailsx/wailsrun`](https://pkg.go.dev/github.com/markbates/wailsx/wailsrun) package. By default, if the [`wailsx.API`](https://pkg.go.dev/github.com/markbates/wailsx#API) type is `nil`, or `zero` (i.e. `\u0026API{}`), all methods will be will be mapped directly to the `wailsrun` package. This allows you to use the [`wailsx.API`](https://pkg.go.dev/github.com/markbates/wailsx#API) type in your application without having to worry about the [`wailsx.API`](https://pkg.go.dev/github.com/markbates/wailsx#API) being `nil`.\n\n\u003ca id=\"figure-1-4\"\u003e\u003c/a\u003e\n\n\n```shell\n$ go doc -short github.com/markbates/wailsx.API\n\ntype API struct {\n\tclipx.ClipboardManager\n\tdialogx.DialogManager\n\teventx.EventManager\n\tlogx.WailsLogger\n\tmenux.MenuManager\n\twindowx.WindowManager\n\n\tBrowserOpenURLFn func(ctx context.Context, url string) error\n\tQuitFn           func(ctx context.Context) error\n}\n\nfunc NewAPI() *API\nfunc NopAPI() *API\nfunc (api *API) BrowserOpenURL(ctx context.Context, url string) error\nfunc (api *API) ClipboardGetText(ctx context.Context) (string, error)\nfunc (api *API) ClipboardSetText(ctx context.Context, text string) error\nfunc (api *API) EventsEmit(ctx context.Context, event string, data ...any) error\nfunc (api *API) EventsOff(ctx context.Context, event string, additional ...string) error\nfunc (api *API) EventsOffAll(ctx context.Context) error\nfunc (api *API) EventsOn(ctx context.Context, event string, callback wailsrun.CallbackFn) (wailsrun.CancelFn, error)\nfunc (api *API) EventsOnMultiple(ctx context.Context, event string, callback wailsrun.CallbackFn, counter int) (wailsrun.CancelFn, error)\nfunc (api *API) EventsOnce(ctx context.Context, event string, callback wailsrun.CallbackFn) (wailsrun.CancelFn, error)\nfunc (api *API) Hide(ctx context.Context) error\nfunc (api *API) LogDebug(ctx context.Context, message string) error\nfunc (api *API) LogDebugf(ctx context.Context, format string, args ...any) error\nfunc (api *API) LogError(ctx context.Context, message string) error\nfunc (api *API) LogErrorf(ctx context.Context, format string, args ...any) error\nfunc (api *API) LogFatal(ctx context.Context, message string) error\nfunc (api *API) LogFatalf(ctx context.Context, format string, args ...any) error\nfunc (api *API) LogInfo(ctx context.Context, message string) error\nfunc (api *API) LogInfof(ctx context.Context, format string, args ...any) error\nfunc (api *API) LogPrint(ctx context.Context, message string) error\nfunc (api *API) LogPrintf(ctx context.Context, format string, args ...any) error\nfunc (api *API) LogSetLogLevel(ctx context.Context, level logger.LogLevel) error\nfunc (api *API) LogTrace(ctx context.Context, message string) error\nfunc (api *API) LogTracef(ctx context.Context, format string, args ...any) error\nfunc (api *API) LogWarning(ctx context.Context, message string) error\nfunc (api *API) LogWarningf(ctx context.Context, format string, args ...any) error\nfunc (api *API) MenuSetApplicationMenu(ctx context.Context, menu *menu.Menu) error\nfunc (api *API) MenuUpdateApplicationMenu(ctx context.Context) error\nfunc (api *API) MessageDialog(ctx context.Context, opts wailsrun.MessageDialogOptions) (string, error)\nfunc (api *API) OpenDirectoryDialog(ctx context.Context, opts wailsrun.OpenDialogOptions) (string, error)\nfunc (api *API) OpenFileDialog(ctx context.Context, opts wailsrun.OpenDialogOptions) (string, error)\nfunc (api *API) OpenMultipleFilesDialog(ctx context.Context, opts wailsrun.OpenDialogOptions) ([]string, error)\nfunc (api *API) Quit(ctx context.Context) error\nfunc (api *API) SaveFileDialog(ctx context.Context, opts wailsrun.SaveDialogOptions) (string, error)\nfunc (api *API) ScreenGetAll(ctx context.Context) ([]wailsrun.Screen, error)\nfunc (api *API) Show(ctx context.Context) error\nfunc (api *API) StateData(ctx context.Context) (statedata.Data[*APIData], error)\nfunc (api *API) WindowCenter(ctx context.Context) error\nfunc (api *API) WindowExecJS(ctx context.Context, js string) error\nfunc (api *API) WindowFullscreen(ctx context.Context) error\nfunc (api *API) WindowGetPosition(ctx context.Context) (int, int, error)\nfunc (api *API) WindowGetSize(ctx context.Context) (int, int, error)\nfunc (api *API) WindowHide(ctx context.Context) error\nfunc (api *API) WindowIsFullscreen(ctx context.Context) (bool, error)\nfunc (api *API) WindowIsMaximised(ctx context.Context) (bool, error)\nfunc (api *API) WindowIsMinimised(ctx context.Context) (bool, error)\nfunc (api *API) WindowIsNormal(ctx context.Context) (bool, error)\nfunc (api *API) WindowMaximise(ctx context.Context) error\nfunc (api *API) WindowMinimise(ctx context.Context) error\nfunc (api *API) WindowPrint(ctx context.Context) error\nfunc (api *API) WindowReload(ctx context.Context) error\nfunc (api *API) WindowReloadApp(ctx context.Context) error\nfunc (api *API) WindowSetAlwaysOnTop(ctx context.Context, b bool) error\nfunc (api *API) WindowSetBackgroundColour(ctx context.Context, R, G, B, A uint8) error\nfunc (api *API) WindowSetDarkTheme(ctx context.Context) error\nfunc (api *API) WindowSetLightTheme(ctx context.Context) error\nfunc (api *API) WindowSetMaxSize(ctx context.Context, width int, height int) error\nfunc (api *API) WindowSetMinSize(ctx context.Context, width int, height int) error\nfunc (api *API) WindowSetPosition(ctx context.Context, x int, y int) error\nfunc (api *API) WindowSetSize(ctx context.Context, width int, height int) error\nfunc (api *API) WindowSetSystemDefaultTheme(ctx context.Context) error\nfunc (api *API) WindowSetTitle(ctx context.Context, title string) error\nfunc (api *API) WindowShow(ctx context.Context) error\nfunc (api *API) WindowToggleMaximise(ctx context.Context) error\nfunc (api *API) WindowUnfullscreen(ctx context.Context) error\nfunc (api *API) WindowUnmaximise(ctx context.Context) error\nfunc (api *API) WindowUnminimise(ctx context.Context) error\n\n--------------------------------------------------------------------------------\nGo Version: go1.22.1\n\n```\n\n\u003e *_Figure 1.4:_ The [`wailsx.API`](https://pkg.go.dev/github.com/markbates/wailsx#API) type*\n\n\nThe [`wailsx.NewAPI`](https://pkg.go.dev/github.com/markbates/wailsx#NewAPI) function can be used to create a new [`wailsx.API`](https://pkg.go.dev/github.com/markbates/wailsx#API) type. This function will populate the [`wailsx.API`](https://pkg.go.dev/github.com/markbates/wailsx#API) type with implementations of its embedded interfaces. For example, using [`eventx.NewManager`](https://pkg.go.dev/github.com/markbates/wailsx/eventx#NewManager) to create a new [`eventx.Manager`](https://pkg.go.dev/github.com/markbates/wailsx/eventx#Manager) that will fill the needed [`eventx.EventManager`](https://pkg.go.dev/github.com/markbates/wailsx/eventx#EventManager) in the [`wailsx.API`](https://pkg.go.dev/github.com/markbates/wailsx#API) type.\n\n\u003ca id=\"figure-1-5\"\u003e\u003c/a\u003e\n\n\n```shell\n$ go doc -short github.com/markbates/wailsx.NewAPI\n\nfunc NewAPI() *API\n    NewAPI returns a new API with all the functions, and interfaces, set to\n    their default implementations.\n\n--------------------------------------------------------------------------------\nGo Version: go1.22.1\n\n```\n\n\u003e *_Figure 1.5:_ The [`wailsx.NewAPI`](https://pkg.go.dev/github.com/markbates/wailsx#NewAPI) function*\n\n\n## \u003ca id=\"heading-36\"\u003e\u003c/a\u003e\u003ctoc-level\u003e1.11.2\u003c/toc-level\u003e - \u003ccode\u003eNil\u003c/code\u003e API Calls\n\n\u003ca id=\"figure-1-6\"\u003e\u003c/a\u003e\n\n\n```go\nfunc Test_Nil_API_Call(t *testing.T) {\n\tt.Parallel()\n\tr := require.New(t)\n\n\tvar api *API\n\n\tctx := context.Background()\n\n\terr := api.Show(ctx)\n\tr.Error(err)\n\n\texp := wailsrun.ErrNotAvailable(\"Show\")\n\tr.Equal(exp, err)\n}\n```\n\u003e *source: doc_test.go:nil-api*\n\n\n\u003e *_Figure 1.6:_ Calling methods on a `nil` [`wailsx.API`](https://pkg.go.dev/github.com/markbates/wailsx#API).*\n\n\n\u003ca id=\"figure-1-7\"\u003e\u003c/a\u003e\n\n\n```shell\n$ go test -v -run Test_Nil_API_Call\n\n=== RUN   Test_Nil_API_Call\n=== PAUSE Test_Nil_API_Call\n=== CONT  Test_Nil_API_Call\n--- PASS: Test_Nil_API_Call (0.00s)\nPASS\nok  \tgithub.com/markbates/wailsx\t0.005s\n\ngo: downloading github.com/markbates/safe v1.1.0\ngo: downloading github.com/wailsapp/wails/v2 v2.8.0\ngo: downloading github.com/stretchr/testify v1.9.0\ngo: downloading github.com/davecgh/go-spew v1.1.1\ngo: downloading github.com/pmezard/go-difflib v1.0.0\ngo: downloading gopkg.in/yaml.v3 v3.0.1\ngo: downloading github.com/leaanthony/slicer v1.6.0\ngo: downloading github.com/leaanthony/u v1.1.1\n\n--------------------------------------------------------------------------------\nGo Version: go1.22.1\n\n```\n\n\u003e *_Figure 1.7:_ Running the test for calling methods on a `nil` [`wailsx.API`](https://pkg.go.dev/github.com/markbates/wailsx#API).*\n\n\n\u003ca id=\"figure-1-8\"\u003e\u003c/a\u003e\n\n\n```shell\n$ go test -v -run Test_Nil_API_Call -tags wails\n\n=== RUN   Test_Nil_API_Call\n=== PAUSE Test_Nil_API_Call\n=== CONT  Test_Nil_API_Call\n2024/03/13 03:52:45 cannot call 'github.com/wailsapp/wails/v2/pkg/runtime.Show': An invalid context was passed. This method requires the specific context given in the lifecycle hooks:\nhttps://wails.io/docs/reference/runtime/intro\nexit status 1\nFAIL\tgithub.com/markbates/wailsx\t0.007s\n\ngo: downloading github.com/markbates/safe v1.1.0\ngo: downloading github.com/wailsapp/wails/v2 v2.8.0\ngo: downloading github.com/stretchr/testify v1.9.0\ngo: downloading github.com/davecgh/go-spew v1.1.1\ngo: downloading github.com/pmezard/go-difflib v1.0.0\ngo: downloading gopkg.in/yaml.v3 v3.0.1\ngo: downloading github.com/leaanthony/slicer v1.6.0\ngo: downloading github.com/leaanthony/u v1.1.1\n\n--------------------------------------------------------------------------------\nGo Version: go1.22.1\n\n```\n\n\u003e *_Figure 1.8:_ Running the test for calling methods on a `nil` [`wailsx.API`](https://pkg.go.dev/github.com/markbates/wailsx#API) in production mode.*\n\n\n## \u003ca id=\"heading-37\"\u003e\u003c/a\u003e\u003ctoc-level\u003e1.11.3\u003c/toc-level\u003e - \u003ccode\u003eNop\u003c/code\u003e API Calls\n\n\u003ca id=\"figure-1-9\"\u003e\u003c/a\u003e\n\n\n```shell\n$ go doc -short github.com/markbates/wailsx.NopAPI\n\nfunc NopAPI() *API\n    NopAPI returns a new API with all the functions, and interfaces, set to\n    no-ops. This is useful for testing.\n\n--------------------------------------------------------------------------------\nGo Version: go1.22.1\n\n```\n\n\u003e *_Figure 1.9:_ The [`wailsx.NopAPI`](https://pkg.go.dev/github.com/markbates/wailsx#NopAPI) function*\n\n\n\u003ca id=\"figure-1-10\"\u003e\u003c/a\u003e\n\n\n```go\nfunc Test_Nop_API_Call(t *testing.T) {\n\tt.Parallel()\n\tr := require.New(t)\n\n\tapi := NopAPI()\n\n\tctx := context.Background()\n\n\terr := api.Show(ctx)\n\tr.NoError(err)\n}\n```\n\u003e *source: doc_test.go:nop-api*\n\n\n\u003e *_Figure 1.10:_ Calling methods on a `nop` [`wailsx.API`](https://pkg.go.dev/github.com/markbates/wailsx#API).*\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkbates%2Fwailsx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarkbates%2Fwailsx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkbates%2Fwailsx/lists"}