event

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

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

Event represents an event that can be fired.

func (*Event) AddHandler

func (e *Event) AddHandler(h HandlerFunc) RemoveHandlerFunc

AddHandler registers event handler with event. It returns a function to remove handler from event.

func (*Event) AddOneTimeHandler added in v0.7.0

func (e *Event) AddOneTimeHandler(handler HandlerFunc)

AddOneTimeHandler registers event handler with event. When event fires, handler is removed from it immediately.

type Fired added in v0.7.0

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

Fired represents an event that has been fired.

type HandlerFunc

type HandlerFunc func(args interface{})

A HandlerFunc is a function that receives and handles an event. When firing an event using EventManager.Fire, arbitrary event arguments may be passed that are in turn passed on to the handler function.

type Manager added in v0.7.0

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

Manager contains queue of fired events. Its role is to handle fire events.

func NewManager added in v0.7.0

func NewManager() *Manager

func (*Manager) Fire added in v0.7.0

func (m *Manager) Fire(e *Event, args any)

Fire fires an event to all registered handlers. Arbitrary event arguments may be passed which are in turn passed on to event handlers.

Events are not fired directly, but are put into a deferred queue. This queue is then processed by the GUI.

func (*Manager) HandleFired added in v0.7.0

func (m *Manager) HandleFired()

HandleFired processes the queue of fired events and calls their handlers.

type RemoveHandlerFunc

type RemoveHandlerFunc func()

RemoveHandlerFunc is a function that removes a handler from an event.

Jump to

Keyboard shortcuts

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