Search

PythonReactSEOPDF
GitHub Skill

patternscallback-context

Callback + Context Pattern (C-Specific) pattern for C development

mgreenly☆ 1 Repository stars0 Repository forks

Installation

Follow the repository instructions for this skill and your agent. Review the files and dependencies before adding it to your workflow.

View source ↗Guides

Skill instructions

Callback + Context Pattern (C-Specific)

Pair function pointer with void * user data. Callback receives user data, enabling state access without globals. Universal C pattern for async/event handling.

ikigai Application

Streaming responses:

typedef void (*chunk_cb_t)(void *user_ctx, const char *data, size_t len);

res_t ik_llm_stream(ik_llm_client_t *client,
                    ik_message_t **msgs,
                    chunk_cb_t on_chunk,
                    void *user_ctx);  // Passed to callback

Usage: REPL passes itself as context, callback updates scrollback.

Convention: Callback function pointer immediately followed by void * context parameter. Callback signature includes context as first param.

Benefit: Stateful callbacks without globals. Each caller provides own context.

Examples

Read the usage examples in the source repository.

View source ↗

Source history

Indexed on
2026-01-20
Index updated
2026-01-26
Branch
main

Index and sync dates describe this directory. View the source repository for code history.

GitHub ↗

chat Comments (0)

chat_bubble_outline

No comments yet. Be the first to share your thoughts!