Re: [whatwg/dom] Improving ergonomics of events with Observable (#544)

Hey, I think it might be interesting to revisit this now that AddEventListenerOptions includes signal with a really smallish API. Maybe something like:


```idl
partial interface EventTarget {
  // since stuff in AddEventListenerOptions like `once` is relevant after subscribing it should probably live there?
  Observable on(DOMString type);
};

[Constructor(/* details elided */)]
interface Observable {
  // unsubscribing already works with AddEventListenerOptions
  void subscribe(Function next, optional Function complete, optional Function error, optional AddEventListenerOptions);
  Promise<void> forEach(Function callback, optional AddEventListenerOptions);
};
```

(I am personally a bit overextended - with the `.follow` document taking _way_ longer than I expected it to mostly because I'm having to learn and research a lot in order to write it).

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/544#issuecomment-770391987

Received on Sunday, 31 January 2021 14:36:46 UTC