class
Godot::BoundSignal
- Godot::BoundSignal
- Reference
- Object
Overview
Represents a signal bound to a specific Godot object instance.
Enables first-class signal handling, inspection, connection, emission, and non-blocking #await.
Examples:
await(enemy.died)
await(enemy.died, timeout_sec: 2.0)
enemy.died.await
enemy.health_changed.connect { |cur, max| puts "Health: #{cur}/#{max}" }
Direct Known Subclasses
Defined in:
libgodot/object.crConstructors
Instance Method Summary
-
#<<(&block : Array(Variant) -> Void) : SignalSubscription
Operator
<<syntactic sugar for#connectwith a block -
#<<(proc : Proc(Array(Variant), R)) : SignalSubscription forall R
Operator
<<syntactic sugar for#connectwith a Proc -
#<<(proc : Proc(R)) : SignalSubscription forall R
Operator
<<syntactic sugar for#connectwith a 0-argument Proc -
#alive? : Bool
Returns true if the bound object is still alive in ObjectDB
-
#await(timeout_sec : Float64 | Nil = nil) : Array(Variant)
Cooperatively awaits this signal without blocking the engine main loop.
-
#await(timeout_sec : Number) : Array(Variant)
Cooperatively awaits this signal with timeout in seconds
-
#connect(flags : ConnectFlags = ConnectFlags::None, callback : Proc(Array(Variant), Void) | Nil = nil) : SignalSubscription
Connects a callback proc to this signal
-
#connect(flags : ConnectFlags = ConnectFlags::None, &block : Array(Variant) -> Void) : SignalSubscription
Connects a callback block to this signal (supports 1-arg
|args|and 0-arg blocks) -
#connect(listener_target : Godot::Object, method_name : Symbol, flags : ConnectFlags = ConnectFlags::None) : SignalSubscription
Connects this signal to a method call on a target object by symbol name
-
#connect_one_shot(&block : Array(Variant) -> Void) : SignalSubscription
Backwards-compatibility helper redirecting to ConnectFlags::OneShot
-
#connected? : Bool
Returns true if this signal currently has any active subscribers
-
#connection_count : Int32
Returns the count of active subscriptions for this signal
-
#disconnect : Void
Disconnects all active subscriptions for this signal on the target
-
#emit(*args) : Void
Emits this signal on the target object
-
#has_connections? : Bool
Alias to
#connected? - #name : String
-
#once(&block : Array(Variant) -> Void) : SignalSubscription
Idiomatic shorthand alias for
#connect_one_shot - #target : Godot::Object
-
#target_id : UInt64
Returns the target's 64-bit instance ID (or Crystal object_id for unparented Crystal nodes)
-
#to_s(io : IO) : Void
Appends a short String representation of this object which includes its class name and its object address.
Constructor Detail
Instance Method Detail
Operator << syntactic sugar for #connect with a 0-argument Proc
Cooperatively awaits this signal without blocking the engine main loop. Returns the emitted arguments as an Array(Variant).
Cooperatively awaits this signal with timeout in seconds
Connects a callback proc to this signal
Connects a callback block to this signal (supports 1-arg |args| and 0-arg blocks)
Connects this signal to a method call on a target object by symbol name
Backwards-compatibility helper redirecting to ConnectFlags::OneShot
Returns the target's 64-bit instance ID (or Crystal object_id for unparented Crystal nodes)
Appends a short String representation of this object which includes its class name and its object address.
class Person
def initialize(@name : String, @age : Int32)
end
end
Person.new("John", 32).to_s # => #<Person:0x10a199f20>