My application has two buttons: start (to consume a stream from the server) and stop (to close the connection using AbortController
). Here are my listeners:
let abortController = new AbortController();
start.addEventListener('click', async () => {
const readable = await consumeAPI(abortController.signal);
readable.pipeTo(appendToHTML(cards));
});
stop.addEventListener('click', () => {
abortController.abort();
console.log('aborting...');
abortController = new AbortController();
})
However, I would like to change the behavior of these buttons to pause and resume the request instead of abort and close.
AbortController MDN seems to have only the abort()
and no other alternatives.
My server is using Readable.toWeb()
from Node streams. I know there is a pause()
and resume()
function but I don't know how to use or how to call them from the client.