Difference between event handlers and callbacks

前端 未结 12 2534
时光说笑
时光说笑 2020-12-22 16:33

What is the difference between an event handler and a callback function?

12条回答
  •  一向
    一向 (楼主)
    2020-12-22 17:13

    Another aspect of this is that events describe something that happened in the past, whereas a callback is often used while something is happening.

    When an event fires, you're being told that something has happened. When a callback is used, you're being asked to participate in something.

    A library or framework might issue events that let you know something has happened. A framework offers you points at which you can plug in code (perhaps as callbacks) so that you can take actively part in a process.

    Part of the problem is that event, callback refer to technical mcehanisms as well as more abstract processes.

提交回复
热议问题