wps-events

Implement and manage Wave Terminal's WPS event system for asynchronous inter-component communication.

22.0k|1.1k|Updated Jun 8, 2022
One-click install
npx skills add https://github.com/wavetermdev/waveterm --skill wps-events
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: wps-events
Source: https://github.com/wavetermdev/waveterm/tree/main/.kilocode/skills/wps-events
Command: npx skills add https://github.com/wavetermdev/waveterm --skill wps-events

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides comprehensive guidance on using Wave Terminal's Publish-Subscribe (WPS) event system, enabling asynchronous communication between different application components.

Core Features & Use Cases

  • Event System Overview: Understand the WPS broker pattern for routing events.
  • Event Structure: Learn the format of WaveEvent including event type, scopes, sender, persistence, and data payload.
  • Adding New Events: Step-by-step instructions for defining new event constants, registering them, and exposing event data types for frontend use.
  • Publishing & Subscribing: Detailed examples for publishing events with and without scopes, asynchronous publishing, and subscribing to events from Go code.
  • Best Practices: Guidelines on using namespaces, avoiding blocking, type-safe data, scoping, documentation, and event persistence.
  • Use Case: When developing a new feature that needs to notify other parts of the application about a change (e.g., a block being closed, a connection status update), this Skill guides you on how to properly define, publish, and subscribe to these events.

Quick Start

Follow the guide to add a new event type named 'my:newevent' with no associated data.

Frequently Asked Questions about wps-events

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement asynchronous communication between components in Go?

Asynchronous communication between Go components is implemented using the Wave Terminal Publish-Subscribe (WPS) event system with a broker pattern for routing events. It enables different application parts to notify each other about changes without direct coupling.

What is the structure of a WaveEvent for the WPS pubsub system?

A WaveEvent in the WPS pubsub system consists of an event type, scopes, sender information, persistence settings, and a data payload. This structure ensures events are properly routed and carry type-safe contextual data for subscribers.

How do I publish and subscribe to events in Go using WPS?

Publishing and subscribing to events in Go using WPS involves calling designated publish functions with or without scopes, including asynchronous options, and setting up subscription handlers in your Go code. Detailed examples guide routing events to the correct listeners.

What are the best practices for event-driven architecture in Wave Terminal?

Best practices for event-driven architecture in Wave Terminal include using namespaces for event types, avoiding blocking operations, ensuring type-safe data payloads, properly scoping events, documenting events, and configuring event persistence appropriately.

When should I use scoped events in the WPS event system?

Scoped events in the WPS event system should be used when you need to restrict event delivery to specific contexts or listeners, such as limiting notifications to a particular window or component rather than broadcasting globally to all subscribers.