User custom signal with the same api as the built-in signals.

Naming the function signature arguments, if any, is recommended for improved error messages:

final myCustomSignal = new CustomSignal<(name:String) -> Void>("myCustomSignal");

Constructor

@:value({ name : "" })new(name:String = "")

Create a new custom signal.

Parameters:

name

Optional name, used for improved debug info.

Methods

connect(callback:T):Void

Connects the custom signal to the callback.

A signal can only be connected once to a callback. It will throw an error if already connected. To avoid this, first, use isConnected to check for existing connections.

disconnect(callback:T):Void

Disconnects the custom signal from the callback.

If you try to disconnect a connection that does not exist, the method will throw an error. Use isConnected to ensure that the connection exists.

emitSignal(args:Rest<Any>):Void

Emit the custom signal.

The arguments type and number are checked at compile time.

isConnected(callback:T):Bool

Returns true if a connection exists between this custom signal and the callback.