Unregister Button Pressed Callback

Does anyone know how to unregister/unbind a callback function from a button pressed event when done using it? Thanks!

That’s not possible.


Unofficial Response
I feel like there is a reason why callback functions are not used by the majority. You have very little control of what you can do, and that can also be bad in a situation in competition where time is of the essence. I would suggest avoiding callback functions (or events) as much as possible unless it is necessary.

1 Like

Event based programming can be really useful and powerful, it just has to be used correctly and understanding the implications.

It wouldn’t make sense in a lot of cases to dynamically bind and unbind callback functions in a context such as a driver control program in robotics.


I honestly agree it can be useful (like possibly binding screen touched events onto the V5 Brain if thats an option) but I feel like programming the robot event’s use case is negligible, which is why events are almost never used in PROS (I don’t even think is an option) unless I am mistaken.

Thanks everyone for your input.

Most programming constructs can be used and abused. As @OscarMNOVA12 mentions, dynamically binding/unbinding callbacks would seem to be an abuse of an event-based programming model.

One could certainly make a case (as, I believe the Vex C++ API does) that Controller button press events can be handled by reasonable call-back functions.

One could certainly envision a call-back anytime one does polling. For example, OkapiLib makes use of an “isSettled” function to allow asynchronous movements. For example:

 while(!drivetrain.isSettled()) {

Might be expressed more event-y as:

drivetrain.doActionAtPoint(somePoint, releaseObjectFromLiftFunction);

Coding is as much about telling the computer what to do as it is communicating to other programmers (including future-self you) what should happen.