events

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package events provides a simple event system for the ALNS.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseEvent1

type BaseEvent1[T any] struct {
	// contains filtered or unexported fields
}

BaseEvent1 is a base event type that can be used to implement events with one payload.

func (*BaseEvent1[T]) Register

func (e *BaseEvent1[T]) Register(handler Handler1[T])

Register adds an event handler for this event.

func (*BaseEvent1[T]) Trigger

func (e *BaseEvent1[T]) Trigger(payload T)

Trigger sends out an event with the payload.

type BaseEvent2

type BaseEvent2[S any, T any] struct {
	// contains filtered or unexported fields
}

BaseEvent2 is a base event type that can be used to implement events with two payloads.

func (*BaseEvent2[S, T]) Register

func (e *BaseEvent2[S, T]) Register(handler Handler2[S, T])

Register adds an event handler for this event.

func (*BaseEvent2[S, T]) Trigger

func (e *BaseEvent2[S, T]) Trigger(payload1 S, payload2 T)

Trigger sends out an event with the payload.

type Handler1

type Handler1[T any] func(payload T)

Handler1 is a function that handles an event with one payload.

type Handler2

type Handler2[S any, T any] func(payload1 S, payload2 T)

Handler2 is a function that handles an event with two payloads.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL