Handling coroutines

Godot Version

4.4

Question

I have following:

script 1 that emits signal_x

script 2 that has connection defined with:
signal_x.connect(_on_some_custom_trigger)

it will have function Y, that has “await signal_x”
and separate function “_on_some_custom_trigger”

in my “_on_some_custom_trigger” I have some logic that I want to be run , before function Y resumes processing. But right now, once signal is emitted, function Y will resume instantly and “_on_some_custom_trigger” won’t have enough time to perform it’s operations.

How to best handle it ? Add another signal into the _on_some_custom_trigger and make function Y also wait on it?

Get rid of the coroutine. Split Y into a part before and a part after the signal. Call second part from _on_some_custom_trigger()

If you insist on having a coroutine, then yes, you’ll have to introduce another signal and await for it in Y