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:
lapis/cs_extras/signal_operators.crlapis/extras/operators.cr
libgodot/signals/bound_signal.cr
Constructors
Instance Method Summary
- #+(proc : Proc(Array(Variant), R)) : self forall R
-
#+(proc : Proc(T, R)) : self forall T, R
Operator
#+for 1-argument typed Proc (supports `sig += ->(player : Player) { ... -
#+(proc : Proc(T0, T1, R)) : self forall T0, T1, R
Operator
#+for 2-argument typed Proc (supports `sig += ->(player : Player, sword : Sword) { ... - #+(proc : Proc(R)) : self forall R
-
#+(sub : SignalSubscription) : self
Operator
#+syntactic sugar accepting a SignalSubscription directly -
#-(proc : Proc) : self
Operator
#-syntactic sugar for disconnecting a Proc (supportssig -= ->handler) -
#-(sub : SignalSubscription) : self
Operator
#-syntactic sugar for disconnecting a SignalSubscription (supportssig -= sub) -
#<<(&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 -
#>(proc : Proc(Array(Variant), R)) : SignalSubscription forall R
Strict pipe (>) to a Proc accepting raw Variant array or 0-arg Proc
- #>(proc : Proc(R)) : SignalSubscription forall R
-
#>(target_signal : BoundSignal) : SignalSubscription
Strict pipe (>): Dispatches to target signal passing raw arguments
-
#>>(target_signal : TypedSignal(*U)) : SignalSubscription forall U
Loose pipe (>>) to a strongly-typed TypedSignal(*U) with automatic downcasting & arity adaptation
-
#>>(proc : Proc(Array(Variant), R)) : SignalSubscription forall R
Loose pipe (>>) to a Proc accepting raw Variant array
-
#>>(proc : Proc(*U, R)) : SignalSubscription forall U, R
Loose pipe (>>) to any N-argument typed Proc(*U, R) with automatic arity trimming, polymorphic downcasting, and numeric coercion.
-
#>>(target_signal : BoundSignal) : SignalSubscription
Loose / adaptive pipe (>>): Dispatches with arity trimming and type downcasting
-
#>>(receiver_method : Tuple(Godot::Object, String | Symbol)) : SignalSubscription
Loose pipe (>>) to a target object and method tuple:
sig >> {target, :on_event} -
#active? : Bool
Returns true if the bound object is active and not destroyed
-
#alive? : Bool
Returns true if the bound object is still alive in ObjectDB
-
#await(timeout_sec : Float64 | Nil = nil) : AwaitStatus(Array(Variant))
Cooperatively awaits this signal without blocking the engine main loop.
-
#await(timeout_sec : Number) : AwaitStatus(Array(Variant))
Cooperatively awaits this signal with timeout in seconds
-
#await!(timeout_sec : Float64 | Nil = nil) : Array(Variant)
Cooperatively awaits this signal, returning the emitted arguments as Array(Variant), or raising Godot::TimeoutError if timeout_sec expires.
- #await!(timeout_sec : Number) : Array(Variant)
-
#await?(timeout_sec : Float64 | Nil = nil) : Array(Variant) | Nil
Cooperatively awaits this signal, returning Array(Variant)?, or nil if timeout_sec expires.
- #await?(timeout_sec : Number) : Array(Variant) | Nil
-
#clear : self
Fluent alias for disconnect_all
-
#connect(flags : ConnectFlags = ConnectFlags::None, callback : Proc(Array(Variant), Void) | Nil = nil, receiver : Godot::Object | Nil = nil) : SignalSubscription
Connects a callback proc to this signal
-
#connect(flags : ConnectFlags = ConnectFlags::None, receiver : Godot::Object | Nil = nil, &block : Array(Variant) -> Void) : SignalSubscription
Connects a callback block to this signal (supports 1-arg
|args|and 0-arg blocks) -
#connect(receiver : Godot::Object, flags : ConnectFlags = ConnectFlags::None, &block : Array(Variant) -> Void) : SignalSubscription
Connects a callback block to this signal with explicit receiver tracking as first positional argument
-
#connect(type0 : T0.class, flags : ConnectFlags = ConnectFlags::None, &block : T0 -> Void) : SignalSubscription forall T0
Connects with 1 positional type filter
-
#connect(type0 : T0.class, type1 : T1.class, flags : ConnectFlags = ConnectFlags::None, &block : T0, T1 -> Void) : SignalSubscription forall T0, T1
Connects with 2 positional type filters
-
#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 : self
Disconnects all active subscriptions for this signal on the target
-
#disconnect_all : self
Disconnects all active subscriptions for this signal on the target (alias)
-
#emit(*args) : self
Emits this signal on the target object
-
#has_connections? : Bool
Alias to
#connected? - #name : String
-
#once(type0 : T0.class, type1 : T1.class, &block : T0, T1 -> Void) : SignalSubscription forall T0, T1
One-shot listener with 2 positional type filters
-
#once(type0 : T0.class, &block : T0 -> Void) : SignalSubscription forall T0
One-shot listener with 1 positional type filter
-
#once(&block : Array(Variant) -> Void) : SignalSubscription
Idiomatic shorthand alias for
#connect_one_shot -
#pipe_to(target_signal : BoundSignal, strict : Bool = false) : SignalSubscription
Pipes this signal to target signal
- #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.
Instance methods inherited from class Object
try?(&)try? try?
Constructor Detail
Instance Method Detail
Operator #+ for 1-argument typed Proc (supports sig += ->(player : Player) { ... })
Operator #+ for 2-argument typed Proc (supports sig += ->(player : Player, sword : Sword) { ... })
Operator #- syntactic sugar for disconnecting a Proc (supports sig -= ->handler)
Operator << syntactic sugar for #connect with a 0-argument Proc
Strict pipe (>) to a Proc accepting raw Variant array or 0-arg Proc
Strict pipe (>): Dispatches to target signal passing raw arguments
Loose pipe (>>) to a strongly-typed TypedSignal(*U) with automatic downcasting & arity adaptation
Loose pipe (>>) to a Proc accepting raw Variant array
Loose pipe (>>) to any N-argument typed Proc(*U, R) with automatic arity trimming, polymorphic downcasting, and numeric coercion.
Loose / adaptive pipe (>>): Dispatches with arity trimming and type downcasting
Loose pipe (>>) to a target object and method tuple: sig >> {target, :on_event}
Cooperatively awaits this signal without blocking the engine main loop. Returns an AwaitStatus(Array(Variant)) indicating completion or timeout.
Cooperatively awaits this signal with timeout in seconds
Cooperatively awaits this signal, returning the emitted arguments as Array(Variant), or raising Godot::TimeoutError if timeout_sec expires.
Cooperatively awaits this signal, returning Array(Variant)?, or nil if timeout_sec expires.
Connects a callback proc to this signal
Connects a callback block to this signal (supports 1-arg |args| and 0-arg blocks)
Connects a callback block to this signal with explicit receiver tracking as first positional argument
Connects with 1 positional type filter
Connects with 2 positional type filters
Connects this signal to a method call on a target object by symbol name
Backwards-compatibility helper redirecting to ConnectFlags::OneShot
Disconnects all active subscriptions for this signal on the target (alias)
One-shot listener with 2 positional type filters
One-shot listener with 1 positional type filter
Pipes this signal to target signal
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>