Documentation ¶
Index ¶
- type Border
- type Color
- type Presettable
- type Prop
- func (p *Prop[T]) ClearCache()
- func (p *Prop[T]) Get(ctx context.Context, context interface{}, params ...interface{}) (value T, ok bool)
- func (p *Prop[T]) GetPreset() (value T, ok bool)
- func (p *Prop[T]) MarshalJanet() interface{}
- func (p *Prop[T]) Preset(ctx context.Context, context interface{}, params ...interface{})
- func (p *Prop[T]) SetLogger(log zerolog.Logger)
- func (p *Prop[T]) SetTTL(ttl time.Duration)
- func (p *Prop[T]) Static() (value T, ok bool)
- func (p *Prop[T]) UnmarshalJanet(value *janet.Value) error
- type String
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Presettable ¶
type Presettable interface { Preset( ctx context.Context, context interface{}, params ...interface{}, ) SetLogger(log zerolog.Logger) ClearCache() }
Presettable is a general interface for providing preset values to many properties at once.
type Prop ¶
type Prop[T any] struct { // contains filtered or unexported fields }
Prop is a property that can be either static or dynamic. If it is static, it will always return the same value. If it is dynamic, it will call a Janet function to calculate the value.
func (*Prop[T]) ClearCache ¶
func (p *Prop[T]) ClearCache()
ClearCache clears the cache of the property, forcing it to be recalculated on the next call to Get if necessary.
func (*Prop[T]) Get ¶
func (p *Prop[T]) Get( ctx context.Context, context interface{}, params ...interface{}, ) (value T, ok bool)
Get returns the value of the property. If the property is static, it will return the value and true. If the property is dynamic, it will call the function with the context and parameters and return the result.
func (*Prop[T]) GetPreset ¶
GetPreset returns the value of the property, computing it using the preset values provided in the Preset method.
func (*Prop[T]) MarshalJanet ¶
func (p *Prop[T]) MarshalJanet() interface{}
func (*Prop[T]) Preset ¶
Preset sets the context and parameters for the property ahead of time. This is useful for properties that are dynamic and need to be calculated with a specific context and parameters.
func (*Prop[T]) SetLogger ¶
SetLogger sets the logger for the property. This is useful for debugging purposes.
func (*Prop[T]) SetTTL ¶
SetTTL sets the time-to-live for the property. This is the amount of time to wait before recalculating the property.