event

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 30, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const OrderDefault = 0

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event[T EventData] struct {
	// contains filtered or unexported fields
}

func New

func New[T EventData]() *Event[T]

func (*Event[T]) Emit

func (e *Event[T]) Emit(data T)

func (*Event[T]) EmitAsync

func (e *Event[T]) EmitAsync(data T)

func (*Event[T]) Subscribe

func (e *Event[T]) Subscribe(call func(*T)) *EventSubscription[*T]

type EventData

type EventData interface{}

type EventSubscription

type EventSubscription[T EventData] struct {
	// contains filtered or unexported fields
}

func NewSubscription

func NewSubscription[T EventData](call func(T), unsubscribe func()) *EventSubscription[T]

func (*EventSubscription[T]) Order

func (s *EventSubscription[T]) Order(order int) *EventSubscription[T]

Order sets the execution order of the subcription. Higher numbers mean later execution.

func (*EventSubscription[T]) Unsubscribe

func (s *EventSubscription[T]) Unsubscribe()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳