johnnystefan/test-saas-business/pattern-observer

Claude Code and agent skill by johnnystefan/test-saas-business

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Teaches and applies the Observer behavioral design pattern — defining a subscription mechanism to notify multiple objects about events in the observed object. Trigger: When implementing event-driven systems, reactive updates, or pub/sub mechanisms.

Install

npx vskill@latest install johnnystefan/test-saas-business/pattern-observer

SKILL.md

The same SKILL.md was published earlier as johnnystefan/test-saas-business/pattern-observer.

Skill: Implement Observer Pattern

Purpose

Defines a subscription mechanism to notify multiple objects about any events that happen to the object they are observing. Essential for event-driven systems, real-time updates, and reactive architectures.

Procedural Instructions

  1. Identify the Publisher: The object with the interesting state that others need to react to.
  2. Declare Subscriber Interface: Usually a single update() method with event data as parameter.
  3. Implement Subscription Logic: Add subscribe(), unsubscribe(), and notify() methods to the Publisher.
  4. Trigger Notifications: The Publisher calls update() on all its subscribers whenever an important event occurs.

TypeScript Example

typescript
interface Subscriber {
update(event: string, data: unknown): void;
}
class Store {
// Publisher
private subscribers: Map<string, Subscriber[]> = new Map();
subscribe(event: string, subscriber: Subscriber) {
if (!this.subscribers.has(event)) {
this.subscribers.set(event, []);
}
this.subscribers.get(event)!.push(subscriber);
}
unsubscribe(event: string, subscriber: Subscriber) {
const subs = this.subscribers.get(event) ?? [];
this.subscribers.set(
event,
subs.filter((s) => s !== subscriber),
);
}
notify(event: string, data: unknown) {
(this.subscribers.get(event) ?? []).forEach((s) => s.update(event, data));
}
changeStock(item: string, quantity: number) {
// ... update logic
this.notify('stockChanged', { item, quantity });
}
}
class EmailAlert implements Subscriber {
update(event: string, data: unknown) {
console.log(`Email sent for event: ${event}`, data);
}
}

Payoff

  • OCP: Introduce new subscriber classes without changing the publisher's code.
  • Dynamic Relationships: Objects can subscribe and unsubscribe at runtime.
  • Loose Coupling: Publisher and subscribers only know about the shared interface.

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
5

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/johnnystefan/test-saas-business/pattern-observer/badge)](https://verified-skill.com/skills/johnnystefan/test-saas-business/pattern-observer)

Something wrong with this skill or its page? Tell us.