module

package
v0.0.0-...-15a9106 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2023 License: Apache-2.0, BSD-2-Clause Imports: 2 Imported by: 34

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Interface

type Interface interface {
	// TriggerConstructed triggers the constructed event.
	TriggerConstructed()

	// WasConstructed returns true if the constructed event was triggered.
	WasConstructed() bool

	// HookConstructed registers a callback for the constructed event.
	HookConstructed(func(), ...event.Option) *event.Hook[func()]

	// TriggerInitialized triggers the initialized event.
	TriggerInitialized()

	// WasInitialized returns true if the initialized event was triggered.
	WasInitialized() bool

	// HookInitialized registers a callback for the initialized event.
	HookInitialized(func(), ...event.Option) *event.Hook[func()]

	// TriggerStopped triggers the stopped event.
	TriggerStopped()

	// WasStopped returns true if the stopped event was triggered.
	WasStopped() bool

	// HookStopped registers a callback for the stopped event.
	HookStopped(func(), ...event.Option) *event.Hook[func()]
}

Interface defines the interface of a module.

type Module

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

Module is a trait that exposes a lifecycle related API, that can be used to create a modular architecture where different modules can listen and wait for each other to reach certain states.

func (*Module) HookConstructed

func (m *Module) HookConstructed(callback func(), opts ...event.Option) *event.Hook[func()]

HookConstructed registers a callback for the constructed event.

func (*Module) HookInitialized

func (m *Module) HookInitialized(callback func(), opts ...event.Option) *event.Hook[func()]

HookInitialized registers a callback for the initialized event.

func (*Module) HookStopped

func (m *Module) HookStopped(callback func(), opts ...event.Option) *event.Hook[func()]

HookStopped registers a callback for the stopped event.

func (*Module) TriggerConstructed

func (m *Module) TriggerConstructed()

TriggerConstructed triggers the constructed event.

func (*Module) TriggerInitialized

func (m *Module) TriggerInitialized()

TriggerInitialized triggers the initialized event.

func (*Module) TriggerStopped

func (m *Module) TriggerStopped()

TriggerStopped triggers the stopped event.

func (*Module) WasConstructed

func (m *Module) WasConstructed() bool

WasConstructed returns true if the constructed event was triggered.

func (*Module) WasInitialized

func (m *Module) WasInitialized() bool

WasInitialized returns true if the initialized event was triggered.

func (*Module) WasStopped

func (m *Module) WasStopped() bool

WasStopped returns true if the stopped event was triggered.

type Provider

type Provider[ContainerType any, ModuleType Interface] func(ContainerType) ModuleType

Provider is a function that returns a module.

func Provide

func Provide[ContainerType any, ModuleType Interface](constructor func(ContainerType) ModuleType) Provider[ContainerType, ModuleType]

Provide turns a constructor into a provider.

Jump to

Keyboard shortcuts

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