From f9aa4d3b602f56240ea07b19007f3126012f3ea1 Mon Sep 17 00:00:00 2001 From: Dana Woodman Date: Wed, 17 Jan 2024 03:40:12 -0800 Subject: [PATCH] Give explicity example of importing JS runtime (#3178) * Give explicity example of importing JS runtime No where in the docs, google, github issues or discussions could I find an example of importing the runtime JS but after some experimentation I figured it out. I think it would help future users if a simple example was shown like this so they have a clear reference of how to import the runtime. * make generic * Update changelog.mdx --------- Co-authored-by: Lea Anthony --- website/src/pages/changelog.mdx | 1 + .../version-v2.7.0/reference/runtime/intro.mdx | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/website/src/pages/changelog.mdx b/website/src/pages/changelog.mdx index c24d93e80..f8868d429 100644 --- a/website/src/pages/changelog.mdx +++ b/website/src/pages/changelog.mdx @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Add Apple Silicon hardware detection to `wails doctor`. Changed by @almas1992 in [PR](https://github.com/wailsapp/wails/pull/3129) - Remove quarantine attribute on macOS binaries. Changed by @leaanthony in [PR](https://github.com/wailsapp/wails/pull/3118) - Added documentation for a common GStreamer error on Linux systems. Changed by [@mkwsnyder](https://github.com/mkwsnyder) in [PR](https://github.com/wailsapp/wails/pull/3134) +- Added documentation on explicity example of importing JS runtime. Changed by [@danawoodman](https://github.com/danawoodman) in [PR](https://github.com/wailsapp/wails/pull/3178) - Add dock icon right-click exit handling by @almas1992 in [PR](https://github.com/wailsapp/wails/pull/3157) ### Fixed diff --git a/website/versioned_docs/version-v2.7.0/reference/runtime/intro.mdx b/website/versioned_docs/version-v2.7.0/reference/runtime/intro.mdx index 3c491ecf0..9174e9f80 100644 --- a/website/versioned_docs/version-v2.7.0/reference/runtime/intro.mdx +++ b/website/versioned_docs/version-v2.7.0/reference/runtime/intro.mdx @@ -34,6 +34,13 @@ The JavaScript library is available to the frontend via the `window.runtime` map mode that provides TypeScript declarations for the runtime. This should be located in the `wailsjs` directory in your frontend directory. +e.g. if you wanted to import the [EventsOn](./events/#eventson) function in your frontend, you can do the following: + +```ts +// src/index.js (for example) +import { EventsOn } from '../wailsjs/runtime' +``` + ### Hide Go: `Hide(ctx context.Context)`