Skip to content

Signal

Allows the creation of custom events.


Constructor

Signal.new()

Creates a new Signal object.

1
local signal = Signal.new()

Methods

Fire(Variant args...)

Fire the event with any number of arguments.

1
signal:Fire("Hello world")

Wait()

Yields until the next time the event is fired, and returns anything that the fired event passed.

1
local message = signal:Wait()

WaitPromise()

Returns a Promise that resolves when the event fires next.

1
2
3
signal:WaitPromise():Then(function(message)
    print(message)
end)

Connect(Function handler)

Connects a function to the event. The function will be called every time the event is fired.

Returns: Connection

1
2
3
signal:Connect(function(message)
    print("Event fired! Got message:", message)
end)

DisconnectAll()

Disconnects all connected functions.

1
signal:DisconnectAll()

Destroy()

Destroys the event, which also disconnects all connections.

1
signal:Destroy()