effect-pubsub-event-bus

Build a typed publish/subscribe event bus using Effect PubSub and Stream.

22|1|Updated Apr 14, 2026
One-click install
npx skills add https://github.com/mpsuesser/pi-effect-harness --skill effect-pubsub-event-bus
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: effect-pubsub-event-bus
Source: https://github.com/mpsuesser/pi-effect-harness/tree/main/harnesses/effect/skills/effect-pubsub-event-bus
Command: npx skills add https://github.com/mpsuesser/pi-effect-harness --skill effect-pubsub-event-bus

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Effect developers need a reliable way to coordinate publish/subscribe communication without messy callback lifecycles, untyped payloads, or manual cleanup that can cause leaks and inconsistent shutdown behavior.

Core Features & Use Cases

  • Typed event definitions: Use discriminated unions with Schema.TaggedClass so publishers and subscribers agree on payload shape.
  • Stream-based subscriptions: Turn PubSub channels into composable Streams via Stream.fromPubSub, enabling filtering, mapping, and backpressure behavior.
  • Scoped, automatic cleanup: Use Effect.forkScoped and finalizers to ensure subscriptions and PubSub shutdown happen when the owning Scope ends.
  • Event-driven service architecture: Replace imperative event buses with reactive, stream-first designs for inter-service domain events.

Quick Start

Implement an event union with Schema.TaggedClass, create a Bus Layer that uses PubSub plus Stream.fromPubSub, and subscribe with forkScoped so cleanup is tied to the layer scope.

Frequently Asked Questions about effect-pubsub-event-bus

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

FAQPage Schema
How do I build a typed event bus with Effect PubSub and Streams?

Build a typed event bus by defining a discriminated union with Schema.TaggedClass, creating a PubSub, and converting it to a Stream via Stream.fromPubSub. This enables strongly validated event payloads for service communication.

What is the best way to manage Effect PubSub subscription cleanup?

Manage PubSub subscription cleanup deterministically using Effect.forkScoped and finalizers. This ties the subscription lifecycle and PubSub shutdown to the owning Scope, preventing resource leaks when the scope ends.

How do I filter and map events in an Effect Stream subscription?

Filter and map events in an Effect Stream subscription by applying stream operators to the Stream generated from Stream.fromPubSub. This composable approach enables reactive processing of typed event payloads.

When should I use an Effect Stream event bus over imperative callbacks?

Use an Effect Stream event bus over imperative callbacks when you need reactive, stream-first designs for inter-service domain events. It replaces messy callback lifecycles with composable streams and scoped fiber management.

Does Effect PubSub support backpressure for stream-based subscribers?

Yes, Effect PubSub supports backpressure for stream-based subscribers. Converting the PubSub channel into a Stream via Stream.fromPubSub enables backpressure behavior alongside filtering and mapping operations.

Can I use Schema.TaggedClass for discriminated union event modeling in Effect?

Yes, you can use Schema.TaggedClass for discriminated union event modeling in Effect. It ensures publishers and subscribers agree on payload shape, providing strongly validated event payloads for your event bus.