6deef76427
Funciones Go para crear apps Wails: scaffold estructura, bind CRUD genérico, build multiplataforma, emit eventos y stream de datos al frontend. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
36 lines
1.1 KiB
Markdown
36 lines
1.1 KiB
Markdown
---
|
|
name: wails_emit_event
|
|
kind: function
|
|
lang: go
|
|
domain: infra
|
|
version: "1.0.0"
|
|
purity: impure
|
|
signature: "WailsEmitEvent(ctx context.Context, eventName string, data interface{})"
|
|
description: "Emite eventos tipados de Go al frontend con timestamp automático. Incluye WailsEmitJSON para serialización explícita."
|
|
tags: [wails, event, emit, ipc, realtime, infra]
|
|
uses_functions: []
|
|
uses_types: []
|
|
returns: []
|
|
returns_optional: false
|
|
error_type: "error_go_core"
|
|
imports: [context, encoding/json, fmt, time, github.com/wailsapp/wails/v2/pkg/runtime]
|
|
tested: false
|
|
tests: []
|
|
test_file_path: ""
|
|
file_path: "functions/infra/wails_emit_event.go"
|
|
---
|
|
|
|
## Ejemplo
|
|
|
|
```go
|
|
// Emitir evento tipado
|
|
WailsEmitEvent(ctx, "price:update", PriceData{Symbol: "BTC", Price: 67500.0})
|
|
|
|
// El frontend lo recibe con useWailsEvent:
|
|
// useWailsEvent({ eventName: 'price:update', onEvent: (data) => ... })
|
|
```
|
|
|
|
## Notas
|
|
|
|
El evento llega al frontend como WailsEventPayload con `type`, `data` y `timestamp`. Complementa `use_wails_event` del lado TS. Requiere la dependencia `github.com/wailsapp/wails/v2` en el proyecto destino.
|