Is there a way to get notified when a loop is entered?

I’m looking to expand on my Loop Composer tool ()

I’m having trouble keeping track of what loop range is currently in progress.

The current code does assorted tracking to see if it has iterated over a particular loop range enough times, and if so, and it it is in the last pattern of that loop range, it schedules the next loop range.

And this works fine. I want to add code that does some additional scripting (such as fading in a track over the duration of a loop).

Because the code is changing the loop end points in preparation of moving to the next loop (as defined by a script provided by the user) the code cannot always check the current loop start and end patterns.

I was thinking that what would make things easier would be a way to get notified when a loop is first entered.

I came across renoise.song().transport.loop_pattern_observable but I cannot get it to trigger a functions.

What is this observable for? When does it get triggered?

Is there a way to get notified when a loop is first entered?

UPDATE: After some hacking about I found that loop_pattern_observable gets triggered when I click on the button for looping the current pattern.