Decide Events

When to use Events & Listeners vs direct calls. Decoupling decisions.

attac-t cf429cd 2 files · 3.1 KB Updated

File contents

Skill: Events

"Events are for side effects. Actions are for intent."

The Decision

Use Events when:

  • Side effects can multiply (notifications, logs, syncs)
  • Consumers don't need the result
  • Cross-domain communication is needed
  • The trigger shouldn't know about all consequences

Use Direct Calls when:

  • The caller needs a return value
  • There's exactly one consumer, forever
  • Failure must halt the operation

The Heuristic

Ask: "If I add another consequence later, should the caller change?"

  • No → Event
  • Yes → Direct call

The Quick Test

Ask Yourself Answer Use
Multiple reactions possible? Yes Event
Caller needs result? Yes Direct
External system involved? Yes Event
Single, obvious dependency? Yes Direct

Real-World Examples

For concrete examples, see examples.md.

attac-t/the-foundry/tree/main/plugins/laravel-ddd/skills/decide-events commit cf429cd29f

Frequently asked questions

npx skillmds@latest add attac-t/decide-events