Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EventListeners defined as classes implementing a call method cannot be used in dart:html #12116

Closed
jacob314 opened this issue Jul 29, 2013 · 5 comments
Labels
type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@jacob314
Copy link
Member

EventListeners defined as classes implementing a call method cannot be used in dart:html
Elsewhere in the system implementing a call method is just as good as implementing a function interface.

Repro:

import 'dart:html';

class MyEventListener {
  call(someEvent) {
    print("I was called");
  }
}

void main() {
  var listener = new MyEventListener();
  print("$listener is an EventListener? ${(listener is EventListener)}");
  window.onResize.listen(listener);
}

Output:
Instance of 'MyEventListener' is an EventListener? true

Exception: Not a Dart closure passed Window.dart:127
Window.$dom_addEventListener Window.dart:127
_EventStreamSubscription._tryResume EventStreamProvider.dart:58
_EventStreamSubscription._EventStreamSubscription EventStreamProvider.dart:23
_EventStream.listen EventStreamProvider.dart:12
main sunflower.dart:93

@madsager
Copy link
Contributor

Added Triaged label.

@a-siva
Copy link
Contributor

a-siva commented Sep 18, 2013

Added this to the Later milestone.

@DartBot
Copy link

DartBot commented Feb 16, 2014

This comment was originally written by b.nos...@gmail.com


i was trying to work out how to use a class instance rather than a function instance for listening to events. I ran into this very issue. Is there a way to get a callback on my own object instances?

@kasperl
Copy link

kasperl commented Jul 10, 2014

Removed this from the Later milestone.
Added Oldschool-Milestone-Later label.

@kasperl
Copy link

kasperl commented Aug 4, 2014

Removed Oldschool-Milestone-Later label.

@kevmoo kevmoo added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) and removed priority-unassigned labels Feb 29, 2016
@vsmenon vsmenon removed their assignment Jun 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

8 participants