5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-02 23:20:51 +08:00
wails/website/versioned_docs/version-v2.0.0-beta.34/reference/runtime/intro.mdx
Misitebao 78c6705cc3
feat(website): improve website content (#1309)
Update Chinese translation
2022-04-04 20:05:54 +10:00

48 lines
1.4 KiB
Plaintext

---
sidebar_position: 1
---
# Introduction
The runtime is a library that provides utility methods for your application. There is both a Go and Javascript runtime
and the aim is to try and keep them at parity where possible.
The Go Runtime is available through importing `github.com/wailsapp/wails/v2/pkg/runtime`. All methods in this package
take a context as the first parameter. This context should be obtained from the [OnStartup](../../reference/options#onstartup)
or [OnDomReady](../../reference/options#ondomready) hooks.
:::info Note
Whilst the context will be provided to the
[OnStartup](../../reference/options#onstartup) method, there's no guarantee the runtime will work in this method as
the window is initialising in a different thread. If
you wish to call runtime methods at startup, use [OnDomReady](../../reference/options#ondomready).
:::
The Javascript library is available to the frontend via the `window.runtime` map. There is a runtime package generated when using `dev`
mode that provides Typescript declarations for the runtime. This should be located in the `wailsjs` directory in your
frontend directory.
### Quit
Go Signature: `Quit(ctx context.Context)`
Quits the application.
### Environment
Go Signature: `Enviromnent(ctx context.Context) EnvironmentInfo`
Returns details of the current environment.
#### EnvironmentInfo
```go
type EnvironmentInfo struct {
BuildType string // Either "production", "debug" or "dev"
}
```