xstate-event-emitter

Manage XState v5 event emission with emit() actions and actor.on() subscriptions.

Updated Feb 12, 2026
One-click install
npx skills add https://github.com/IlyaGulya/claude-marketplace --skill xstate-event-emitter
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: xstate-event-emitter
Source: https://github.com/IlyaGulya/claude-marketplace/tree/main/plugins/xstate/skills/xstate-event-emitter
Command: npx skills add https://github.com/IlyaGulya/claude-marketplace --skill xstate-event-emitter

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill addresses the need to manage and communicate events that originate from within an XState machine and are intended for external listeners, decoupling internal state transitions from external side effects.

Core Features & Use Cases

  • Emit Events: Use the emit() action creator to send events from machine transitions or actor logic.
  • Subscribe to Events: Listen for emitted events using actor.on() with specific event types or a wildcard.
  • Type Safety: Define and enforce types for emitted events using the setup configuration.
  • Use Case: In a form submission machine, emit a toast event with a success or error message to be handled by the UI layer, without the machine needing to know how toasts are displayed.

Quick Start

Use the xstate-event-emitter skill to emit a 'notification' event with the message 'Form submitted successfully'.

Frequently Asked Questions about xstate-event-emitter

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

FAQPage Schema
How do I emit events from an XState machine to external listeners?

To emit events from an XState machine, use the `emit()` action creator within machine transitions to send outward-facing events, allowing external handlers to listen via `actor.on()` subscriptions.

How do I decouple UI side effects from core XState machine logic?

To decouple UI side effects from XState logic, use the `emit()` action to send outward-facing events like a toast notification, letting the UI layer handle the effect without the machine knowing the implementation.

Can I use the XState event emitter with TypeScript for type-safe events?

Yes, you can enforce type safety for emitted events in TypeScript by defining and enforcing the event types within the `setup` configuration of your XState machine.

Does the XState event emitter pattern work with different actor types?

Yes, XState outward-facing event emission integrates with various actor types, supporting subscriptions and side effect handling for promises, callbacks, and observables.

What is the best way to subscribe to emitted XState events externally?

The best way to subscribe to emitted XState events is using the `actor.on()` method, which allows external handlers to listen for specific event types or a wildcard to manage outward-facing effects.

Why does my XState machine logic get cluttered with UI side effects?

XState machine logic gets cluttered with UI side effects when transitions directly handle external results. Using the `emit()` action decouples these side effects by sending outward-facing events to external listeners.