IssueRaiser

Improving ergonomics of events with Observable

Observable has been at stage 1 in the TC-39 for over a year now. Under the circumstances we are considering standardizing Observable in the WHATWG. We believe that standardizing Observable in the WHATWG may have the following advantages: * Get Observable to web developers more quickly. * Allow for a more full-featured proposal that will address more developer pain points. * Address concerns raised in the TC-39 that there has not been sufficient consultation with implementers. The goal of this thread is to gauge implementer interest in Observable. Observable can offer the following benefits to web developers: 1. First-class objects representing composable repeated events, similar to how promises represent one-time events 2. Ergonomic unsubscription that plays well with AbortSignal/AbortController 3. Good integration with promises and async/await ### Integrating Observable into the DOM We propose that the "on" method on EventTarget should return an Observable. ```cs partial interface EventTarget { Observable on(DOMString type, optional AddEventListenerOptions options); }; [Constructor(/* details elided */)] interface Observable { AbortController subscribe(Function next, optional Function complete, optional Function error); AbortController subscribe(Observer observer); // TODO this overload is not quite valid Promise<void> forEach(Function callback, optional AbortSignal signal); Observable takeUntil(Observable stopNotifier); Promise<any> f

Posted by benlesh on Dec 13, 2017, 5:58 AM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.4,500 issues0 comments

github (Other)

Improving ergonomics of events with Observable

benleshDec 13, 2017, 5:58 AM

Observable has been at stage 1 in the TC-39 for over a year now. Under the circumstances we are considering standardizing Observable in the WHATWG. We believe that standardizing Observable in the WHATWG may have the following advantages: * Get Observable to web developers more quickly. * Allow for a more full-featured proposal that will address more developer pain points. * Address concerns raised in the TC-39 that there has not been sufficient consultation with implementers. The goal of this thread is to gauge implementer interest in Observable. Observable can offer the following benefits to web developers: 1. First-class objects representing composable repeated events, similar to how promises represent one-time events 2. Ergonomic unsubscription that plays well with AbortSignal/AbortController 3. Good integration with promises and async/await ### Integrating Observable into the DOM We propose that the "on" method on EventTarget should return an Observable. ```cs partial interface EventTarget { Observable on(DOMString type, optional AddEventListenerOptions options); }; [Constructor(/* details elided */)] interface Observable { AbortController subscribe(Function next, optional Function complete, optional Function error); AbortController subscribe(Observer observer); // TODO this overload is not quite valid Promise<void> forEach(Function callback, optional AbortSignal signal); Observable takeUntil(Observable stopNotifier); Promise<any> f

Comments (0)

No comments yet. Start the discussion.

Comment on this issue