simvx.core.signals

Signal and Connection classes: observable event dispatcher.

Leaf module with no engine dependencies. Used by Property descriptors, Selection, UndoStack, EventBus, and any node-attached signal.

Module Contents

Classes

Connection

Handle returned by Signal.connect(). Can disconnect and acts as a callable proxy.

Signal

Observable event dispatcher with optional type metadata.

Data

log

API

simvx.core.signals.log

‘getLogger(…)’

class simvx.core.signals.Connection(signal: simvx.core.signals.Signal, fn: collections.abc.Callable)[source]

Handle returned by Signal.connect(). Can disconnect and acts as a callable proxy.

For bound methods on Nodes (objects exposing _outgoing_connections), the callback is held weakly and the connection auto-cleans when the node is destroyed: matching Godot 4’s signal lifecycle. Other callables (lambdas, free functions, methods on non-Node objects) keep a strong reference.

Initialization

__slots__

(‘_signal’, ‘_fn’, ‘_weak’, ‘_connected’)

disconnect()[source]

Disconnect this callback from the signal.

property connected: bool[source]
__call__(*args, **kwargs)[source]
__bool__()[source]
__repr__()[source]
class simvx.core.signals.Signal(*types: type)[source]

Observable event dispatcher with optional type metadata.

Used as a class attribute, Signal is a non-data descriptor: each instance accessing it lazily gets its own Signal copy stored in obj.__dict__. Class-level access (Cls.signal_name) returns the shared signal: useful for global event hubs like Node.script_error_raised.

Example::

class Player(Node):
    health_changed = Signal(int)          # typed: emits one int

p1, p2 = Player(), Player()
p1.health_changed.connect(on_p1)          # instance-scoped
p1.health_changed(50)                     # only p1 listeners fire

Initialization

__slots__

(‘_callbacks’, ‘_types’, ‘_name’)

classmethod __class_getitem__(params) simvx.core.signals.Signal[source]

Bracket syntax: Signal[int], Signal[int, str].

__set_name__(owner, name)[source]
__get__(obj, objtype=None)[source]
connect(fn: collections.abc.Callable, *, once: bool = False) simvx.core.signals.Connection[source]

Subscribe a callback. Returns a Connection handle.

Args: fn: Callback to invoke on emit. once: If True, auto-disconnect after first emit.

disconnect(fn_or_conn)[source]

Remove a previously connected callback or Connection.

__call__(*args, **kwargs)[source]

Emit the signal, calling all connected callbacks with the given arguments.

Connections whose weak target was garbage-collected are skipped and pruned from _callbacks after the dispatch loop. A callback that disconnects another callback mid-emit only marks the peer _connected=False: the live list still holds it, so an unconditional rebuild after dispatch keeps the invariant that _callbacks only ever contains connected entries.

clear()[source]

Remove all connected callbacks.

disconnect_from_module(module_name: str) int[source]

Drop all connections whose callback is defined in module_name.

Used by the hot-reload system to release references to old-module code (lambdas, free functions, methods) before reload, so the old module can be garbage-collected.

Returns the number of connections dropped.

emit

None

__repr__()[source]