Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Principle:2giosangmitom Sqmeow nvim Event Emission

From Leeroopedia
Knowledge Sources
Domains RPC, Event_Emission
Last Updated 2026-10-16 14:00 GMT

Overview

An event notification principle that communicates operation outcomes from the engine to the editor through named events carrying MessagePack payloads, with acceptance replies queued before completion events.

Description

Event Emission is the principle of reporting the outcome of long-running operations (query execution, edit application, view computation, schema introspection, export) through named event notifications sent from the engine to the Neovim editor. Short operations return values directly through the RPC reply; long operations return an acknowledgement first, then emit completion events.

This principle addresses the challenge of keeping the editor informed about async work: the reply names the accepted id, and subsequent events carry that id so the editor can correlate them. Failures after acceptance are reported through events, not RPC errors.

Standard events:

  • call:state — Query execution lifecycle: "executing", "done", "error", "cancelled".
  • call:view — View computation result: row count, aggregated flag, summary.
  • conn:state — Connection lifecycle: "connecting", "connected", "error".
  • apply:done — Edit application outcome: success or error.
  • schema:nodes — Schema tree level for the drawer.
  • structure:done — Table columns, indexes, and details.
  • export:done — Export outcome: text/path, rows, bytes, or error.

Usage

Use this principle when designing an async RPC system: short operations reply directly; long operations accept then emit. Every event carries the id from the acceptance reply for correlation.

Theoretical Basis

The principle follows the acceptance-before-work notification pattern:

  1. Acceptance: The RPC reply (e.g., Value::from(call_id)) is queued before tokio::spawn starts the work.
  2. Events follow: Completion events (e.g., call:state) always arrive after the reply, carrying the same id.
  3. Payload structure: Events carry a MessagePack map with standard fields (id, state) plus operation-specific fields (columns, rows, error).
  4. Error channel: Failures after acceptance are reported through events, not RPC errors. The event payload includes an error field.
# Abstract pattern (NOT real implementation):
def on_request(method, params, reply):
    call_id = next_id()
    reply.ok(call_id)  # acceptance first
    spawn(work(call_id))  # events follow

def work(call_id):
    result = execute(...)
    emit("call:state", {
        "call_id": call_id,
        "state": "done" if result.ok else "error",
        "columns": [...], "rows": result.row_count,
        "error": result.error,  # only on failure
    })

Related Pages

Implemented By

Uses Heuristic

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment