+1 vote

I have some signal, with potential callables connected to it.
When I emit it, I want to wait for each callback to return before pursuing.
Something like:

await emit_signal('my_sig')

But it return immediatly after launching the callbacks execution.

Complete example:

extends Node

signal sig()

func _ready():
    sig.connect(_on_sig)
    await emit_signal('sig')
    print('emitted !')

func _on_sig():
    await get_tree().create_timer(1).timeout
    print('sig waited')

Is it possible using GDScript signal's implementation, or should I implement my own Publisher-Subscriber ?

Godot version Godot 4 Beta2
in Engine by (19 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.