mediator

package
v1.5.8 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Component = &app.Component{
	Constructor: func(container container.Container) error {
		return container.Provide(NewMediator)
	},
	Serve: func(c container.Container) error {
		closer, err := container.Get[closer.Closer](c)
		if err != nil {
			return err
		}

		ctx, cancelFunc := context.WithCancel(closer.GetContext())
		defer cancelFunc()

		<-ctx.Done()

		mediator, err := container.Get[Mediator](c)
		if err != nil {
			return err
		}

		return mediator.Close()
	},
}

Functions

This section is empty.

Types

type Callback

type Callback func(data any)

type Mediator

type Mediator interface {
	io.Closer
	Subscribe(channel string, callback Callback)
	Send(channel string, data any)
}

func NewMediator

func NewMediator() Mediator

Jump to

Keyboard shortcuts

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