Skip to content

Binding DOM events using observables #10039

@wesleycho

Description

@wesleycho

I'm submitting a ... (check one with "x")

[ ] bug report
[x] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior
With the DOM renderer, one binds events just like one does when using the raw DOM api (i.e. addEventListener).

Expected/desired behavior
Being able to interface with an observable for binding DOM events.

What is the expected behavior?
Being able to interface with an observable for binding DOM events and still retain the benefits of server-side/mobile platform rendering with support for progressive web apps.

What is the motivation / use case for changing the behavior?
Currently there is no exposure to being able to manipulate an observable, which prevents easier implementations of certain behavior, such as throttling a scroll event (say for a scrollspy), or dragging & dropping components. It would also be more in line with rxjs paradigms & its integration within Angular.

Ideally, one should be able to do

this.domRenderer.createListener(this.elementRef.nativeElement, eventName)
  .throttle(50)
  .subscribe(...);

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: coreIssues related to the framework runtimefeatureIssue that requests a new feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions