Skip to content

Commit 6a2a512

Browse files
committed
Added emit method.
1 parent cb0d7eb commit 6a2a512

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Sources/SwiftGodot/Core/GenericSignal.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class GenericSignal<each T: VariantStorable> {
2626
/// - flags: Optional, can be also added to configure the connection's behavior (see ``Object/ConnectFlags`` constants).
2727
/// - Returns: an object token that can be used to disconnect the object from the target on success, or the error produced by Godot.
2828
///
29-
@discardableResult /* Signal1 */
29+
@discardableResult
3030
public func connect(flags: Object.ConnectFlags = [], _ callback: @escaping (_ t: repeat each T) -> Void) -> Object {
3131
let signalProxy = SignalProxy()
3232
signalProxy.proxy = { args in
@@ -46,6 +46,11 @@ public class GenericSignal<each T: VariantStorable> {
4646
target.disconnect(signal: signalName, callable: Callable(object: token, method: SignalProxy.proxyName))
4747
}
4848

49+
/// Emit the signal (with required arguments, if there are any)
50+
public func emit(_ t: repeat each T) {
51+
target.emitSignal(signalName, repeat each t)
52+
}
53+
4954
/// You can await this property to wait for the signal to be emitted once.
5055
public var emitted: Void {
5156
get async {

0 commit comments

Comments
 (0)