connectrpc / connect-es

The TypeScript implementation of Connect: Protobuf RPC that works.
https://connectrpc.com/
Apache License 2.0
1.39k stars 82 forks source link

server side stream should can be colse at js-client. #1256

Closed wxf4150 closed 1 month ago

wxf4150 commented 1 month ago

const client = createPromiseClient(PubService, transport);

let stream=client.tickerChan({str:"ETH"}); for await (const i of stream) { console.log("abc eth",new Date(), i) }; // stream.close(); //should be call here. stream=client.tickerChan({str:"BTC"}); for await (const i of stream) { console.log("abc btc",new Date(), i) };

wxf4150 commented 1 month ago

with above code; only the ETH stream data can work.

wxf4150 commented 1 month ago

createCallbackClient can used for cancel server-side stream.

let cccli = createCallbackClient(PubService, transport) let cancel = cccli.greet({str: "bob"}, res => { console.log(res); }, () => { }) cancel() cancel = cccli.greet({str: "jim"}, res => { console.log(res); }, () => { })