Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/src/content/docs/concepts/architecture.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,9 @@ app.Event.Emit("user-logged-in", user)

```javascript
// JavaScript: Listen for event
import { On } from '@wailsio/runtime'
import { Events } from '@wailsio/runtime'

On('user-logged-in', (user) => {
Events.On('user-logged-in', (user) => {
console.log('User logged in:', user)
})
```
Expand Down
4 changes: 2 additions & 2 deletions docs/src/content/docs/concepts/bridge.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -549,11 +549,11 @@ func ProcessLargeFile(path string) error {
```

```javascript
import { On } from '@wailsio/runtime'
import { Events } from '@wailsio/runtime'
import { ProcessLargeFile } from './bindings/FileService'

// Listen for progress
On('file-progress', (data) => {
Events.On('file-progress', (data) => {
console.log(`Line ${data.line}: ${data.text}`)
})

Expand Down
4 changes: 2 additions & 2 deletions docs/src/content/docs/contributing/binding-system.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,9 @@ export namespace backend {
### JavaScript Side

```ts
import { invoke } from "@wailsio/runtime";
import { System } from "@wailsio/runtime";

await invoke(0x7a1201d3 /* ChatService.Send */, ["Hello"]);
await System.invoke(0x7a1201d3 /* ChatService.Send */, ["Hello"]);
```

Implementation: `runtime/desktop/@wailsio/runtime/invoke.ts`
Expand Down
12 changes: 6 additions & 6 deletions docs/src/content/docs/features/dialogs/custom.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -199,14 +199,14 @@ func ShowConfirmdialog(message string) bool {
</div>

<script>
import { OnEvent, Emit } from '@wailsio/runtime'
import { Events } from '@wailsio/runtime'

OnEvent("set-message", (message) => {
Events.On("set-message", (message) => {
document.getElementById("message").textContent = message
})

function confirm(result) {
Emit(result ? "confirm-yes" : "confirm-no")
Events.Emit(result ? "confirm-yes" : "confirm-no")
}
</script>
```
Expand Down Expand Up @@ -389,17 +389,17 @@ func (ld *Logindialog) Cancel() {
</div>

<script>
import { Emit } from '@wailsio/runtime'
import { Events } from '@wailsio/runtime'

document.getElementById('login-form').addEventListener('submit', (e) => {
e.preventDefault()
const username = document.getElementById('username').value
const password = document.getElementById('password').value
Emit('login-submit', { username, password })
Events.Emit('login-submit', { username, password })
})

function cancel() {
Emit('login-cancel')
Events.Emit('login-cancel')
}
</script>
```
Expand Down
8 changes: 4 additions & 4 deletions docs/src/content/docs/features/events/system.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,13 @@ window.EmitEvent("window-specific-event", data)
### From JavaScript

```javascript
import { Emit } from '@wailsio/runtime'
import { Events } from '@wailsio/runtime'

// Emit to Go
Emit("button-clicked", { buttonId: "submit" })
Events.Emit("button-clicked", { buttonId: "submit" })

// Emit to all windows
Emit("broadcast-message", "Hello everyone")
Events.Emit("broadcast-message", "Hello everyone")
```

## Listening to Events
Expand Down Expand Up @@ -506,7 +506,7 @@ func main() {
**JavaScript:**

```javascript
import { Events, Emit } from '@wailsio/runtime'
import { Events } from '@wailsio/runtime'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Inconsistent Emit usage in the Complete Example section below.

Lines 531 and 537 still use bare Emit(...) calls (e.g., Emit("close-confirmed", true) and Emit("user-action", ...)), but the import on line 509 only brings in Events. These should be updated to Events.Emit(...) to match.

Proposed fix (lines 531 and 537)
-        Emit("close-confirmed", true)
+        Events.Emit("close-confirmed", true)
-    Emit("user-action", { action: "button-clicked" })
+    Events.Emit("user-action", { action: "button-clicked" })
🤖 Prompt for AI Agents
In `@docs/src/content/docs/features/events/system.mdx` at line 509, The example
mixes bare Emit(...) calls with an import that provides Events, so replace the
two bare calls to Emit (e.g., the calls that currently read
Emit("close-confirmed", true) and Emit("user-action", ...)) with
Events.Emit(...) to match the imported symbol; update the two occurrences to
call Events.Emit(...) where Emit is used so the example compiles and
consistently references the Events.Emit API.


// Listen for notifications
Events.On("notification", (event) => {
Expand Down
60 changes: 25 additions & 35 deletions docs/src/content/docs/features/windows/frameless.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,11 @@ Use the `--wails-draggable` CSS property:
**JavaScript for buttons:**

```javascript
import { WindowMinimise, WindowMaximise, WindowClose } from '@wailsio/runtime'
import { Window } from '@wailsio/runtime'

document.querySelector('.minimize').addEventListener('click', WindowMinimise)
document.querySelector('.maximize').addEventListener('click', WindowMaximise)
document.querySelector('.close').addEventListener('click', WindowClose)
document.querySelector('.minimize').addEventListener('click', () => Window.Minimise())
document.querySelector('.maximize').addEventListener('click', () => Window.Maximise())
document.querySelector('.close').addEventListener('click', () => Window.Close())
```

## System Buttons
Expand Down Expand Up @@ -214,38 +214,34 @@ document.querySelector('.close').addEventListener('click', Close)
**Or use runtime methods:**

```javascript
import {
WindowMinimise,
WindowMaximise,
WindowClose
} from '@wailsio/runtime'

document.querySelector('.minimize').addEventListener('click', WindowMinimise)
document.querySelector('.maximize').addEventListener('click', WindowMaximise)
document.querySelector('.close').addEventListener('click', WindowClose)
import { Window } from '@wailsio/runtime'

document.querySelector('.minimize').addEventListener('click', () => Window.Minimise())
document.querySelector('.maximize').addEventListener('click', () => Window.Maximise())
document.querySelector('.close').addEventListener('click', () => Window.Close())
```

### Toggle Maximise State

Track maximise state for button icon:

```javascript
import { WindowIsMaximised, WindowMaximise, WindowUnMaximise } from '@wailsio/runtime'
import { Window } from '@wailsio/runtime'

async function toggleMaximise() {
const isMaximised = await WindowIsMaximised()
const isMaximised = await Window.IsMaximised()

if (isMaximised) {
await WindowUnMaximise()
await Window.Restore()
} else {
await WindowMaximise()
await Window.Maximise()
}

updateMaximiseButton()
}

async function updateMaximiseButton() {
const isMaximised = await WindowIsMaximised()
const isMaximised = await Window.IsMaximised()
const button = document.querySelector('.maximize')
button.textContent = isMaximised ? '❐' : '□'
}
Expand Down Expand Up @@ -737,41 +733,35 @@ body {
**JavaScript:**

```javascript
import {
WindowMinimise,
WindowMaximise,
WindowUnMaximise,
WindowIsMaximised,
WindowClose
} from '@wailsio/runtime'
import { Window } from '@wailsio/runtime'

// Minimise button
document.querySelector('.minimize').addEventListener('click', () => {
WindowMinimise()
Window.Minimise()
})

// Maximise/restore button
const maximiseBtn = document.querySelector('.maximize')
maximiseBtn.addEventListener('click', async () => {
const isMaximised = await WindowIsMaximised()
const isMaximised = await Window.IsMaximised()

if (isMaximised) {
await WindowUnMaximise()
await Window.Restore()
} else {
await WindowMaximise()
await Window.Maximise()
}

updateMaximiseButton()
})

// Close button
document.querySelector('.close').addEventListener('click', () => {
WindowClose()
Window.Close()
})

// Update maximise button icon
async function updateMaximiseButton() {
const isMaximised = await WindowIsMaximised()
const isMaximised = await Window.IsMaximised()
maximiseBtn.textContent = isMaximised ? '❐' : '□'
maximiseBtn.title = isMaximised ? 'Restore' : 'Maximise'
}
Expand Down
11 changes: 5 additions & 6 deletions docs/src/content/docs/guides/events-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -518,13 +518,12 @@ useEffect(() => {
Check platform availability when using platform-specific events:

```javascript
import { Platform, Events } from '@wailsio/runtime';
import { Events } from '@wailsio/runtime';

if (Platform.isWindows) {
Events.On('windows:APMSuspend', handleSuspend);
} else if (Platform.isMac) {
Events.On('mac:ApplicationWillTerminate', handleTerminate);
}
// Platform-specific events can be registered unconditionally;
// they will simply never fire on unsupported platforms.
Events.On('windows:APMSuspend', handleSuspend);
Events.On('mac:ApplicationWillTerminate', handleTerminate);
```

### 4. Don't Overuse Events
Expand Down
6 changes: 3 additions & 3 deletions docs/src/content/docs/migration/v2-to-v3.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -456,13 +456,13 @@ EventsOn("update", (data) => {
EventsEmit("action", data)

// v3
import { OnEvent, Emit } from '@wailsio/runtime'
import { Events } from '@wailsio/runtime'

OnEvent("update", (data) => {
Events.On("update", (data) => {
console.log(data)
})

Emit("action", data)
Events.Emit("action", data)
```

### Step 6: Update Configuration
Expand Down
Loading
Loading