Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConnectOneShot ¶
Types ¶
type Event ¶
type Event[T any] struct { // contains filtered or unexported fields }
Event is a slot-signal container. It holds all currect event listeners and invokes their callbacks when the associated event is triggered. An event is triggered when Emit() method is called.
If you need 0 arguments callback, use Void type for the argument. If you need more than 1 argument in your callback, use tuple helper package. For example, a tuple.Value3[int, float, string] can be used to pass three arguments to your callback.
func (*Event[T]) Connect ¶
func (e *Event[T]) Connect(conn connection, slot func(arg T))
Connect adds an event listener that will be called for every Emit called for this event. When connection is disposed, an associated callback will be unregistered. If this connection should be persistent, pass a nil value as conn. For a non-nil conn, it's possible to disconnect from event by using Disconnect method.
func (*Event[T]) Disconnect ¶
func (e *Event[T]) Disconnect(conn connection)
Disconnect removes an event listener identified by this connection. Note that you can't disconnect a listener that was connected with nil connection object.