Code Explainers
Code explainers tagged #observer-pattern
typescript
type ToastVariant = "info" | "success" | "warning" | "error"; interface Toast { id: string;
A self-dismissing toast store with dedup
observer-pattern
deduplication
timers
Intermediate
10 steps
python
import json import logging import threading from pathlib import Path
A hot-reloading config file watcher
file-watching
thread-safety
hot-reload
Intermediate
7 steps
typescript
type EventMap = Record<string, unknown>; type Handler<T> = (payload: T) => void;
A type-safe event bus in TypeScript
generics
event-emitter
type-safety
Advanced
7 steps
php
<?php namespace App\Events;
A priority event dispatcher in PHP
observer-pattern
callbacks
priority-ordering
Intermediate
8 steps
typescript
type EventMap = Record<string, unknown[]>; type Listener<Args extends unknown[]> = (...args: Args) => void;
A type-safe event emitter in TypeScript
generics
mapped-types
event-emitter
Advanced
8 steps
ruby
class EventEmitter def initialize @listeners = Hash.new { |hash, key| hash[key] = [] } end
Building an EventEmitter in Ruby
pub-sub
closures
callbacks
Intermediate
7 steps