Digital Input Listener?

I am using DigitalIO.getValueStr() to get the current status of digital input 0.
Is it possible to add some sort of listener such that I can run some code everytime the status changes?

I’m considering implementing a thread with the sole purpose of getting the value at every interval.
RTDE actual_digital_input_bits is not working for me for some unknown reason.

If you have any suggestions, I would appreciate it.
Thank you.

Right or wrong, I’ve opted to use a Thread that monitors the state and does actions based on the state change, just like you’re describing. My proof of concept was adding the ability to create and teach waypoints using the Tool IO.

As a workaround, I added the reading of the status of digital input 0 to my RTDE thread.
That is, everytime (100ms interval) my RTDE thread transmits data, I call getDigitalIO(“digital_in[0]”).getValue.
But it seems to cause a delay the saving of other relevant data from the thread.