promise

package
v0.0.0-...-c635e59 Latest Latest
Warning

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

Go to latest
Published: May 20, 2024 License: Apache-2.0, BSD-2-Clause Imports: 2 Imported by: 1

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 is an event that can be triggered exactly once. Consumers that register themselves after the event was triggered, will be called immediately.

func NewEvent

func NewEvent() *Event

NewEvent creates a new Event with 0 generic parameters.

func (*Event) OnTrigger

func (e *Event) OnTrigger(callback func()) (unsubscribe func())

OnTrigger registers a callback that will be called when the event is triggered. If the event was already triggered, the callback will be called immediately.

func (*Event) Trigger

func (e *Event) Trigger() (wasTriggered bool)

Trigger triggers the event. If the event was already triggered, this method does nothing.

func (*Event) WasTriggered

func (e *Event) WasTriggered() bool

WasTriggered returns true if the event was already triggered.

type Event1

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

Event1 is an event with a single parameter that can be triggered exactly once. Consumers that register themselves after the event was triggered, will be called immediately.

func NewEvent1

func NewEvent1[T any]() *Event1[T]

NewEvent1 creates a new event with 1 generic parameter.

func (*Event1[T]) OnTrigger

func (e *Event1[T]) OnTrigger(callback func(T)) (unsubscribe func())

OnTrigger registers a callback that will be called when the event is triggered. If the event was already triggered, the callback will be called immediately.

func (*Event1[T]) Trigger

func (e *Event1[T]) Trigger(arg T) (wasTriggered bool)

Trigger triggers the event. If the event was already triggered, this method does nothing.

func (*Event1[T]) WasTriggered

func (e *Event1[T]) WasTriggered() bool

WasTriggered returns true if the event was already triggered.

Jump to

Keyboard shortcuts

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