简体   繁体   English

如何在Dart中调度事件?

[英]How to dispatch events in Dart?

I read this question: How do I listen for custom events in Dart? 我读了一个问题: 如何在Dart中监听自定义事件?

It tells you to dispatch events like: 它告诉您调度事件,例如:

window.on['foo'].dispatch(new CustomEvent('foo'));

However, with the latest version of Dart SDK, the on is deprecated. 但是,在最新版本的Dart SDK中,不建议使用on So how can I do this? 那我该怎么做呢?

The equivalent code in the latest SDK would be like: 最新SDK中的等效代码如下:

window.dispatchEvent(new CustomEvent('foo'));

It does not need to be any harder than that ;) 它不需要比这更难;)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM