@anzaui/engine - v0.6.0
    Preparing search index...

    Function formatEvent

    • Encode an envelope as one Server-Sent Events message: event: template, data: <envelope JSON>, then a blank line.

      sseEvent (web adapter) is the same function.

      Parameters

      • envelope: Envelope

        The envelope to send.

      Returns string

      The SSE frame, "event: template\ndata: {…}\n\n".

      import { Envelope, formatEvent } from '@anzaui/engine';

      formatEvent(new Envelope('feed', 1724771200, '<article>Live Post</article>'));
      // 'event: template\ndata: {"v":2,"slot":"feed","ts":1724771200,"html":"<article>Live Post</article>"}\n\n'