events

package
v0.0.0-...-1e60831 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: NIST-PD-fallback Imports: 1 Imported by: 1

Documentation

Overview

Package events provides a simple event emitter.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Emitter

type Emitter struct {
	// contains filtered or unexported fields
}

Emitter is a simple event emitter. This is a thin wrapper of emission.Emitter that modifies emitter.On method to return a function that cancels the callback registration.

func NewEmitter

func NewEmitter() *Emitter

NewEmitter creates a simple event emitter.

func (*Emitter) Emit

func (emitter *Emitter) Emit(event any, arguments ...any)

Emit triggers an event.

func (*Emitter) On

func (emitter *Emitter) On(event, listener any) (cancel func())

On registers a callback when an event occurs. Returns a function that cancels the callback registration.

func (*Emitter) Once

func (emitter *Emitter) Once(event, listener any) (cancel func())

Once registers a one-time callback when an event occurs. Returns a function that cancels the callback registration.

Jump to

Keyboard shortcuts

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