Maintenance in progress: we are indexing a large batch of new skills. Some pages may load slowly or briefly show no results. Nothing is lost, and everything is back to normal within the hour.

Patterns/observer

Observer Pattern (Callbacks) pattern for C development

majiayu000 44a2c7a 2 files · 1.3 KB Updated 567 repo stars

File contents

Observer Pattern (Callbacks)

Objects register interest in events and get notified when they occur. In C, implemented as callback function pointers with context.

ikigai Application

Streaming chunks: LLM client notifies REPL as response chunks arrive:

typedef void (*chunk_callback_t)(void *ctx, const char *chunk, size_t len);
res_t ik_llm_stream(client, messages, on_chunk, user_ctx);

Terminal resize: Signal handler notifies REPL of SIGWINCH.

Future uses:

  • Database change notifications
  • Tool execution progress
  • Background task completion

Convention: Always pair callback function pointer with void *user_ctx parameter.

majiayu000/claude-skill-registry-data/tree/main/data/observer commit 44a2c7ac7b

Frequently asked questions

npx skillmds add majiayu000/patterns-observer