utils

package
v0.0.0-...-31d5520 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Log = log.New()
)

Functions

This section is empty.

Types

type Agent

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

func NewAgent

func NewAgent[T any](value T) *Agent[T]

func (*Agent[T]) Get

func (a *Agent[T]) Get() (value T, err error)

func (*Agent[T]) Serve

func (a *Agent[T]) Serve(ctx context.Context) (err error)

func (*Agent[T]) Update

func (a *Agent[T]) Update(update func(T) (T, error)) (T, error)

type Debouncer

type Debouncer struct {
	Delay time.Duration
	Func  func()
	// contains filtered or unexported fields
}

func (Debouncer) Stop

func (d Debouncer) Stop()

func (*Debouncer) Trigger

func (d *Debouncer) Trigger()

type Dispatcher

type Dispatcher[T any] struct {
	*Agent[subscribers[T]]
	NewSubscriberHook func(chan<- T)
}

func NewDispatcher

func NewDispatcher[T any]() *Dispatcher[T]

func (*Dispatcher[T]) Dispatch

func (d *Dispatcher[T]) Dispatch(value T, ctx context.Context) (err error)

func (*Dispatcher[T]) OnNewSubscriber

func (d *Dispatcher[T]) OnNewSubscriber(hook func(chan<- T))

func (*Dispatcher[T]) Subscribe

func (d *Dispatcher[T]) Subscribe() (c <-chan T, cancel func())

Jump to

Keyboard shortcuts

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