"complete" single fired events?
For example, if you have a web socket, and you get a close event, I'm proposing that we just complete it for the user. This of course means identifying different things that are like this and handling them appropriately.
const socket = new WebSocket('wss://whatever');
socket.when('close').subscribe({
next: () => console.log('closed'),
complete: () => console.log('done'),
});
AbortSignal's abort is another one I can think of off the top of my head.
Alternatively, users will just have to add a take(1) to them.
But this does illustrate another advantage to Observable over addEventListener. It also causes the subscription to teardown and clean up, which can cascade through flatMap and other composition.
I can see arguments both ways on this. One potential issue is, how does this react to socket.dispatchEvent(new Event("close"))?
I would assume it would still fire once, then complete. For consistency.
Of course, subscribing again would start waiting for a new close event. But that's interesting.
I guess we would have to look at use cases for dispatching close events manually
+1 and same for error event!