General developer forum

Callback vs Event API

 
Picture of Jeremy Rodríguez Arroyo
Callback vs Event API
 

I´m currently developing on moodle and when developing I realized that  I don´t hava a clear idea about callback functions and event api, somebody can tell me what are the diferences between them.

 
Average of ratings: -
Picture of Dorel Manolescu
Re: Callback vs Event API
 

Hi

From here: https://docs.moodle.org/dev/Callbacks

###

  • Event observers. Each plugin can implement event observers that execute code when event is triggered. See Events API about how to listen to events. Event observers can not always substitute callbacks because they do not return any value and can only happen in case of event. Many "hook points" are necessary before something has happened or when nothing is happening at all, for example a report/summary is gathered. However if it is possible to achieve the desired outcome with event observer, Moodle will not accept requests for adding a "hook point".

###

Regards

 
Average of ratings: -
Picture of Jeremy Rodríguez Arroyo
Re: Callback vs Event API
 

So if I needed to use a new callback function how Can I do ??

I haven´t used observers and event API  yet   ... but I see it´s very similar to events in any other programming lenguage. 

 
Average of ratings: -