• Invokes the streamEndpoint with a new Duplex and returns the client view of that endpoint when the connection has been established.

    Returns

    Returns a StreamHandler which can be written to to stream messages to the server over WebSocket and which can be listened to for messages from the server

    Example

    const client = createApiClient({foo: { simpleStream: ws<"string", "string">("/ws/stream") }});
    const streamHandler = await openStreamHandler(client.foo.simpleStream);

    streamHandler.on("message", (val: boolean) =>
    console.log("Got message from server", val);
    streamHandler.close()
    );
    streamHandler.write("This string is sent to the server");

    Type Parameters

    • Out

    • In

    • Closure

    Parameters

    Returns Promise<StreamHandler<Out, In>>

Generated using TypeDoc