decorator

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Chain

func Chain[T any](component T, decorators ...Decorator[T]) T

Chain decorates the given object with all middlewares.

Types

type Decorator

type Decorator[T any] interface {
	// Decorate wraps the underlying obj, adding some functionality.
	Decorate(component T) T
}

Decorator allows us to write something like decorators to component. It can execute something before invoke or after.

type Func

type Func[T any] func(component T) T

Func is an adapter to allow the use of ordinary functions as Decorator.

func (Func[T]) Decorate

func (f Func[T]) Decorate(component T) T

Decorate call f(obj).

Jump to

Keyboard shortcuts

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