Skip to content

Commit

Permalink
Added emit method.
Browse files Browse the repository at this point in the history
  • Loading branch information
samdeane committed Oct 25, 2024
1 parent cb0d7eb commit 6a2a512
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Sources/SwiftGodot/Core/GenericSignal.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class GenericSignal<each T: VariantStorable> {
/// - flags: Optional, can be also added to configure the connection's behavior (see ``Object/ConnectFlags`` constants).
/// - Returns: an object token that can be used to disconnect the object from the target on success, or the error produced by Godot.
///
@discardableResult /* Signal1 */
@discardableResult
public func connect(flags: Object.ConnectFlags = [], _ callback: @escaping (_ t: repeat each T) -> Void) -> Object {
let signalProxy = SignalProxy()
signalProxy.proxy = { args in
Expand All @@ -46,6 +46,11 @@ public class GenericSignal<each T: VariantStorable> {
target.disconnect(signal: signalName, callable: Callable(object: token, method: SignalProxy.proxyName))
}

/// Emit the signal (with required arguments, if there are any)
public func emit(_ t: repeat each T) {
target.emitSignal(signalName, repeat each t)
}

/// You can await this property to wait for the signal to be emitted once.
public var emitted: Void {
get async {
Expand Down

0 comments on commit 6a2a512

Please sign in to comment.