You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
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?
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
The text was updated successfully, but these errors were encountered: