I want to do something like
// WARNING: this code does not work, it's illustrative
query("#myBtn").onClick.listen((e) {
window.fire["foo"];
});
window.on["foo"].listen((e) => print("foo was here"));
window.on["foo"].listen((e) => print("and here"));
Is it possible? How? I've been searching on Google for a few hours now, but I'm kind of new to programming in general, so I don't really know any keywords for this sort of thing.
Thanks! :)
-- EDIT: Solved --
Here's how to pass arguments along (The editor will complain, but it works)
List<String> myData = ["one","two"];
query("#myBtn").onClick.listen((e) {
window.on["foo"].dispatch(new CustomEvent("foo", canBubble: false, cancelable: false, detail: myData));
});
window.on["foo"].add((e) => print( e.detail[1] ));
:-)