Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DataProvider ¶
DataProvider is a contract on how the data for the Feature container can be fetched. It is expected that either found instance is returned or error occurred during invocation.
type DataProviderFunc ¶
DataProviderFunc defines function signature which is used for fetching data. This allows to pass simple closures while construction data providers.
type DataProviderWithDefault ¶
type DataProviderWithDefault[T any] struct { // contains filtered or unexported fields }
DataProviderWithDefault allows to define a value and optional means of supplying it if original value is empty. When the original value is zero the alternative can be provided using: - `OrElse` to define a static value - `OrGet` to perform dynamic lookup by providing DataProviderFunc.
func ValueOf ¶
func ValueOf[T any](value T) DataProviderWithDefault[T]
ValueOf is a constructor which allows to define a value with optional provider.
func (DataProviderWithDefault[T]) Get ¶
Get returns Value() of Defaulter and ensures DataProviderWithDefault can be used as DataProviderFunc.
func (DataProviderWithDefault[T]) OrElse ¶
func (d DataProviderWithDefault[T]) OrElse(other T) DataProviderFunc[T]
OrElse allows to define static default value when the stored one is a zero-value.
func (DataProviderWithDefault[T]) OrGet ¶
func (d DataProviderWithDefault[T]) OrGet(getFunc DataProviderFunc[T]) DataProviderFunc[T]
OrGet allows to define dynamic value provider when the stored one is a zero-value.
func (DataProviderWithDefault[T]) Value ¶
func (d DataProviderWithDefault[T]) Value() T
Value returns actual value stored by the provider.
type Defaulter ¶
type Defaulter[T any] interface { Value() T OrElse(other T) DataProviderFunc[T] OrGet(getFunc DataProviderFunc[T]) DataProviderFunc[T] }
Defaulter defines how a default value can be supplied when original one is zero-value.