From harness-claude
> Notify subscribers automatically when an observable object's state changes
npx claudepluginhub intense-visions/harness-engineering --plugin harness-claudeThis skill uses the workspace's default tool permissions.
> Notify subscribers automatically when an observable object's state changes
Implements typed push-based Observer pattern for notifying dependents on state changes. Use for loose-coupled event systems, reactive bindings, or in-process pub/sub.
Implements reactive programming patterns with RxJS observables, streams, and backpressure for event-driven UIs, async data streams, and complex data flows.
Provides RxJS code patterns for Angular apps: observable creation, HttpClient integration, transformation operators like map/switchMap, and filtering like take/filter for async operations.
Share bugs, ideas, or general feedback.
Notify subscribers automatically when an observable object's state changes
observers array and subscribe / unsubscribe / notify methods.notify(data) whenever the observable's state changes — it invokes all subscribed callbacks.unsubscribe — failing to unsubscribe causes memory leaks in long-lived apps.EventTarget or EventEmitter (Node.js) over hand-rolled implementations.class Observable {
constructor() {
this.observers = [];
}
subscribe(fn) {
this.observers.push(fn);
return () => this.unsubscribe(fn); // return cleanup function
}
unsubscribe(fn) {
this.observers = this.observers.filter((obs) => obs !== fn);
}
notify(data) {
this.observers.forEach((fn) => fn(data));
}
}
const store = new Observable();
const cleanup = store.subscribe((data) => console.log('Received:', data));
store.notify({ type: 'UPDATE', payload: 42 });
cleanup(); // unsubscribe
subscribe — consumers call it to remove the handler.The Observer pattern (also called pub/sub) separates the emitter (subject/observable) from its consumers (observers/subscribers). This decoupling is fundamental to event-driven architectures, reactive state systems, and streams.
Trade-offs:
notify() during developmentWhen NOT to use:
https://patterns.dev/javascript/observer-pattern