class Godot::TypedSignal(*T)

Overview

Strongly-typed signal binding offering compile-time type safety and zero-allocation dispatch via Lapis::Core::StaticSignalTable.

Defined in:

lapis/cs_extras/signal_operators.cr
lapis/extras/operators.cr
libgodot/signals/typed_signal.cr

Constructors

Instance Method Summary

Instance methods inherited from class Godot::BoundSignal

+(proc : Proc(Array(Variant), R)) : self forall R
+(proc : Proc(T, R)) : self forall T, R
+(proc : Proc(T0, T1, R)) : self forall T0, T1, R
+(proc : Proc(R)) : self forall R
+(sub : SignalSubscription) : self
+
, -(proc : Proc) : self
-(sub : SignalSubscription) : self
-
, <<(&block : Array(Variant) -> Void) : SignalSubscription
<<(proc : Proc(Array(Variant), R)) : SignalSubscription forall R
<<(proc : Proc(R)) : SignalSubscription forall R
<<
, >(proc : Proc(Array(Variant), R)) : SignalSubscription forall R
>(proc : Proc(R)) : SignalSubscription forall R
>(target_signal : BoundSignal) : SignalSubscription
>
, >>(target_signal : TypedSignal(*U)) : SignalSubscription forall U
>>(proc : Proc(Array(Variant), R)) : SignalSubscription forall R
>>(proc : Proc(*U, R)) : SignalSubscription forall U, R
>>(target_signal : BoundSignal) : SignalSubscription
>>(receiver_method : Tuple(Godot::Object, String | Symbol)) : SignalSubscription
>>
, active? : Bool active?, alive? : Bool alive?, await(timeout_sec : Float64 | Nil = nil) : AwaitStatus(Array(Variant))
await(timeout_sec : Number) : AwaitStatus(Array(Variant))
await
, await!(timeout_sec : Float64 | Nil = nil) : Array(Variant)
await!(timeout_sec : Number) : Array(Variant)
await!
, await?(timeout_sec : Float64 | Nil = nil) : Array(Variant) | Nil
await?(timeout_sec : Number) : Array(Variant) | Nil
await?
, clear : self clear, connect(flags : ConnectFlags = ConnectFlags::None, callback : Proc(Array(Variant), Void) | Nil = nil, receiver : Godot::Object | Nil = nil) : SignalSubscription
connect(flags : ConnectFlags = ConnectFlags::None, receiver : Godot::Object | Nil = nil, &block : Array(Variant) -> Void) : SignalSubscription
connect(receiver : Godot::Object, flags : ConnectFlags = ConnectFlags::None, &block : Array(Variant) -> Void) : SignalSubscription
connect(type0 : T0.class, flags : ConnectFlags = ConnectFlags::None, &block : T0 -> Void) : SignalSubscription forall T0
connect(type0 : T0.class, type1 : T1.class, flags : ConnectFlags = ConnectFlags::None, &block : T0, T1 -> Void) : SignalSubscription forall T0, T1
connect(listener_target : Godot::Object, method_name : Symbol, flags : ConnectFlags = ConnectFlags::None) : SignalSubscription
connect
, connect_one_shot(&block : Array(Variant) -> Void) : SignalSubscription connect_one_shot, connected? : Bool connected?, connection_count : Int32 connection_count, disconnect : self disconnect, disconnect_all : self disconnect_all, emit(*args) : self emit, has_connections? : Bool has_connections?, name : String name, once(type0 : T0.class, type1 : T1.class, &block : T0, T1 -> Void) : SignalSubscription forall T0, T1
once(type0 : T0.class, &block : T0 -> Void) : SignalSubscription forall T0
once(&block : Array(Variant) -> Void) : SignalSubscription
once
, pipe_to(target_signal : BoundSignal, strict : Bool = false) : SignalSubscription pipe_to, target : Godot::Object target, target_id : UInt64 target_id, to_s(io : IO) : Void to_s

Constructor methods inherited from class Godot::BoundSignal

new(target : Godot::Object, name : String) new

Instance methods inherited from class Object

try?(&)
try?
try?

Constructor Detail

def self.new(target : Godot::Object, name : String) #

Instance Method Detail

def +(proc : Proc(Array(Variant), R)) : self forall R #

Operator #+ syntactic sugar for #connect with a Proc accepting raw Variant array


def +(proc : Proc(U0, R)) : self forall U0, R #

Operator #+ for 1-argument typed Proc (supports exact types and downcasting via StaticSignalTable)


def +(proc : Proc(U0, U1, R)) : self forall U0, U1, R #

Operator #+ for 2-argument typed Proc (supports exact types and downcasting via StaticSignalTable)


def +(proc : Proc(R)) : self forall R #

Operator #+ syntactic sugar for 0-argument Proc (supports sig += ->handler)


def +(sub : SignalSubscription) : self #

Operator #+ syntactic sugar accepting a SignalSubscription directly


def -(proc : Proc) : self #

Operator #- syntactic sugar for disconnecting a Proc (supports sig -= ->handler)


def -(sub : SignalSubscription) : self #

Operator #- syntactic sugar for disconnecting a SignalSubscription (supports sig -= sub)


def <<(&block : *T -> Void) : SignalSubscription #

Operator << syntactic sugar for type-safe connect with a block


def <<(proc : Proc(*T, R)) : SignalSubscription forall R #

Operator << syntactic sugar for type-safe connect with a Proc


def <<(proc : Proc(R)) : SignalSubscription forall R #

Operator << syntactic sugar for 0-argument Proc


def >(target_signal : TypedSignal(*T)) : SignalSubscription #

Strict pipe (>): Exact signature match required at compile-time!


def >(proc : Proc(*T, R)) : SignalSubscription forall R #

Strict pipe (>): Exact signature match required at compile-time; binds directly to StaticSignalTable without wrapper closure.


def >>(target_signal : TypedSignal(*U)) : SignalSubscription forall U #

Loose / adaptive pipe (>>): Accepts ANY TypedSignal(*U)!


def >>(proc : Proc(Array(Variant), R)) : SignalSubscription forall R #

Loose pipe (>>) to a Proc accepting raw Variant array


def >>(proc : Proc(*U, R)) : SignalSubscription forall U, R #

Loose / adaptive pipe (>>) to any N-argument Proc(*U, R):

  • If T == U: binds directly to StaticSignalTable via bind(proc).
  • If T.size >= U.size: connects via TypedSignal#connect (StaticSignalTable fast path) with arity trimming and polymorphic downcasting.

def >>(target_signal : BoundSignal) : SignalSubscription #

Loose pipe (>>) to a dynamic BoundSignal:


def await(timeout_sec : Float64 | Nil = nil) #
Description copied from class Godot::BoundSignal

Cooperatively awaits this signal without blocking the engine main loop. Returns an AwaitStatus(Array(Variant)) indicating completion or timeout.


def await(timeout_sec : Number) #
Description copied from class Godot::BoundSignal

Cooperatively awaits this signal with timeout in seconds


def await!(timeout_sec : Float64 | Nil = nil) #

Cooperatively awaits this signal, returning the unwrapped value, or raising Godot::DisposedObjectError if the target is freed, or Godot::TimeoutError if timeout_sec expires.


def await!(timeout_sec : Number) #

def await?(timeout_sec : Float64 | Nil = nil) #

Cooperatively awaits this signal, returning the value or nil if timeout_sec expires or the target is freed. For 0-argument signals, returns true if completed, false if timed out, or nil if the target is freed.


def await?(timeout_sec : Number) #

def bind(proc : Proc(*T, R), flags : ConnectFlags = ConnectFlags::None, once : Bool = false, receiver : Godot::Object | Nil = nil) : SignalSubscription forall R #

Binds a pre-constructed Proc(*T, R) directly to the underlying StaticSignalTable slot without intermediate closure wrapping on the typed fast path.


def bind(once : Bool = false, flags : ConnectFlags = ConnectFlags::None, receiver : Godot::Object | Nil = nil, &block : *T -> Void) : SignalSubscription #

Block overload for #bind delegating to #connect with optional #once flag.


def bind_slot(proc : Proc(*T, R), once : Bool = false) : UInt64 forall R #

Binds a compile-time typed Proc(*T, R) directly to the StaticSignalTable slot without allocating a SignalSubscription, returning the 64-bit slot token.


def bind_slot(once : Bool = false, &block : *T -> Void) : UInt64 #

Binds a typed block directly to the StaticSignalTable slot, returning the 64-bit slot token.


def connect(flags : ConnectFlags = ConnectFlags::None, receiver : Godot::Object | Nil = nil, &block : *T -> Void) : SignalSubscription #

Type-safe connect binding directly to StaticSignalTable for zero-allocation emission, while maintaining a synchronized SignalSubscription for lifecycle and dynamic fallback.


def connect(receiver : Godot::Object, flags : ConnectFlags = ConnectFlags::None, &block : *T -> Void) : SignalSubscription #

Overload allowing receiver as first positional argument: sig.connect(receiver) { |args| ... }


def connect_one_shot(&block : *T -> Void) : SignalSubscription #

Backwards-compatibility helper redirecting to ConnectFlags::OneShot


def emit(*args : *T) : self #

Emits this typed signal with strictly ZERO GC heap allocations on the typed hot path.


def once(&block : *T -> Void) : SignalSubscription #

Idiomatic shorthand alias for #connect_one_shot


def signal_hash : UInt64 #

def static_slot : Lapis::Core::StaticSignalSlot(*T) #

Returns the zero-allocation Lapis::Core::StaticSignalSlot(*T) backing this signal.


def unbind(proc : Proc(*T, R)) : Bool forall R #

Unbinds a typed Proc(*T, R) from this signal.


def unbind(token : UInt64) : Bool #

Unbinds a listener by its 64-bit StaticSignalTable token.