1

Node Events 事件触发器 once 问题

 2 years ago
source link: https://www.v2ex.com/t/808091
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

V2EX  ›  Node.js

Node Events 事件触发器 once 问题

  AmiKara · 1 天前 · 420 次点击

看教程的过程中看到一个例子,觉得蛮奇怪的 https://www.nodejs.red/#/nodejs/events?id=%e7%bc%96%e7%a0%81%e5%ae%9e%e7%8e%b0

这个解决并发问题的下面大篇幅的讲了 once 和 on 的区别,但是我亲手实践发现这里文件查找的例子将 once 换成 on 结果也是一样的, 这里难道不是基于 status 控制状态,readFile 是异步所以才能产生这个结果吗,为什么非要用 once 来解决,感觉用 on 来解决这里的问题也是一样的。。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK