Function subscribeToSSE

  • Open an SSE subscription to the relay at the given path (e.g. /drive, /drive/<id>, /item?drive=<id>).

    Type Parameters

    • TDoc = any
    • TStart = any

    Parameters

    Returns SSESubscription

    A subscription handle. Call close() to disconnect.

    const sub = subscribeToSSE('/drive', {
    onStart: (info) => console.log('connected', info),
    onUpdate: (doc) => console.log('drive changed', doc),
    onError: (err) => console.error(err),
    });

    // later
    sub.close();