binding

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2024 License: MIT Imports: 8 Imported by: 1

Documentation

Overview

Enthält eine Sammlung von gebundenen Datentypen.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bool

type Bool interface {
	DataItem
	Get() bool
	Set(bool)
}

Bool supports binding a bool value.

func NewBool

func NewBool() Bool

NewBool returns a bindable bool value that is managed internally.

func StringToBool added in v1.2.1

func StringToBool(str String) Bool

StringToBool creates a binding that connects a String data item to a Bool. Changes to the String will be parsed and pushed to the Bool if the parse was successful, and setting the Bool update the String binding.

func StringToBoolWithFormat added in v1.2.1

func StringToBoolWithFormat(str String, format string) Bool

StringToBoolWithFormat creates a binding that connects a String data item to a Bool and is presented using the specified format. Changes to the Bool will be parsed and if the format matches and the parse is successful it will be pushed to the String. Setting the Bool will push a formatted value into the String.

type Bytes

type Bytes interface {
	DataItem
	Get() []byte
	Set([]byte)
}

Bytes supports binding a []byte value.

func NewBytes

func NewBytes() Bytes

NewBytes returns a bindable []byte value that is managed internally.

type CallbackFunc

type CallbackFunc func(data DataItem)

Neben den DataListeners gibt es noch eine schlanke Variante seinen Code bei Veränderungen eines Bind-Objektes aufrufen zu lassen: man kann einfach eine Funktion/Methode, welche dem Typ CallbackFunc entspricht, mit AddCallback hinzufügen.

type DataItem

type DataItem interface {
	AddListener(l DataListener)
	RemoveListener(l DataListener)
	AddCallback(f CallbackFunc)
	RemoveCallback(f CallbackFunc)
}

Mit DataItem ist das minimale Interface definiert welches ein Bind-Objekt implementieren muss. Einem Bind-Objekt können einerseits Objekte hinzugefügt werden, die das DataListener Interface implementieren, andererseits aber auch direkt Funktionen vom Typ CallbackFunc. Diese beiden Möglichkeiten können auch zusammen, d.h. synchron verwendet werden.

type DataListener

type DataListener interface {
	DataChanged(data DataItem)
}

Alle Typen, welche über die Aenderungen von Bind-Objekten informiert werden wollen, müssen das DataListener-Interface implementieren. Im Wesentlichen eine einzige Methode (DataChanged), welche als Argument das veränderte Bind-Objekt hat.

func NewDataListener

func NewDataListener(fn func(data DataItem)) DataListener

Mit NewDataListener kann einfach und bequem ein neues Listener-Objekt erzeugt werden.

type DataMap added in v1.2.1

type DataMap interface {
	DataItem
	GetItem(string) (DataItem, error)
	Keys() []string
}

DataMap is the base interface for all bindable data maps.

Since: 2.0

type ExternalBool

type ExternalBool interface {
	Bool
	Reload()
}

ExternalBool supports binding a bool value to an external value.

func BindBool

func BindBool(v *bool) ExternalBool

BindBool returns a new bindable value that controls the contents of the provided bool variable. If your code changes the content of the variable this refers to you should call Reload() to inform the bindings.

type ExternalBytes

type ExternalBytes interface {
	Bytes
	Reload()
}

ExternalBytes supports binding a []byte value to an external value.

func BindBytes

func BindBytes(v *[]byte) ExternalBytes

BindBytes returns a new bindable value that controls the contents of the provided []byte variable. If your code changes the content of the variable this refers to you should call Reload() to inform the bindings.

type ExternalFloat

type ExternalFloat interface {
	Float
	Reload()
}

ExternalFloat supports binding a float64 value to an external value.

func BindFloat

func BindFloat(v *float64) ExternalFloat

BindFloat returns a new bindable value that controls the contents of the provided float64 variable. If your code changes the content of the variable this refers to you should call Reload() to inform the bindings.

type ExternalInt

type ExternalInt interface {
	Int
	Reload()
}

ExternalInt supports binding a int value to an external value.

func BindInt

func BindInt(v *int) ExternalInt

BindInt returns a new bindable value that controls the contents of the provided int variable. If your code changes the content of the variable this refers to you should call Reload() to inform the bindings.

type ExternalRune

type ExternalRune interface {
	Rune
	Reload()
}

ExternalRune supports binding a rune value to an external value.

func BindRune

func BindRune(v *rune) ExternalRune

BindRune returns a new bindable value that controls the contents of the provided rune variable. If your code changes the content of the variable this refers to you should call Reload() to inform the bindings.

type ExternalString

type ExternalString interface {
	String
	Reload()
}

ExternalString supports binding a string value to an external value.

func BindString

func BindString(v *string) ExternalString

BindString returns a new bindable value that controls the contents of the provided string variable. If your code changes the content of the variable this refers to you should call Reload() to inform the bindings.

type ExternalUntyped

type ExternalUntyped interface {
	Untyped
	Reload()
}

ExternalUntyped supports binding a interface{} value to an external value.

func BindUntyped

func BindUntyped(v interface{}) ExternalUntyped

BindUntyped returns a new bindable value that controls the contents of the provided interface{} variable. If your code changes the content of the variable this refers to you should call Reload() to inform the bindings.

type ExternalUntypedMap added in v1.2.1

type ExternalUntypedMap interface {
	UntypedMap
	Reload() error
}

ExternalUntypedMap is a map data binding with all values untyped (interface{}), connected to an external data source.

Since: 2.0

func BindUntypedMap added in v1.2.1

func BindUntypedMap(d *map[string]interface{}) ExternalUntypedMap

BindUntypedMap creates a new map binding of string to interface{} based on the data passed. If your code changes the content of the map this refers to you should call Reload() to inform the bindings.

Since: 2.0

type Float

type Float interface {
	DataItem
	Get() float64
	Set(float64)
}

Float supports binding a float64 value.

func NewFloat

func NewFloat() Float

NewFloat returns a bindable float64 value that is managed internally.

func StringToFloat added in v1.2.1

func StringToFloat(str String) Float

StringToFloat creates a binding that connects a String data item to a Float. Changes to the String will be parsed and pushed to the Float if the parse was successful, and setting the Float update the String binding.

func StringToFloatWithFormat added in v1.2.1

func StringToFloatWithFormat(str String, format string) Float

StringToFloatWithFormat creates a binding that connects a String data item to a Float and is presented using the specified format. Changes to the Float will be parsed and if the format matches and the parse is successful it will be pushed to the String. Setting the Float will push a formatted value into the String.

type Int

type Int interface {
	DataItem
	Get() int
	Set(int)
}

Int supports binding a int value.

func NewInt

func NewInt() Int

NewInt returns a bindable int value that is managed internally.

func StringToInt added in v1.2.1

func StringToInt(str String) Int

StringToInt creates a binding that connects a String data item to a Int. Changes to the String will be parsed and pushed to the Int if the parse was successful, and setting the Int update the String binding.

func StringToIntWithFormat added in v1.2.1

func StringToIntWithFormat(str String, format string) Int

StringToIntWithFormat creates a binding that connects a String data item to a Int and is presented using the specified format. Changes to the Int will be parsed and if the format matches and the parse is successful it will be pushed to the String. Setting the Int will push a formatted value into the String.

type Rune

type Rune interface {
	DataItem
	Get() rune
	Set(rune)
}

Rune supports binding a rune value.

func NewRune

func NewRune() Rune

NewRune returns a bindable rune value that is managed internally.

type String

type String interface {
	DataItem
	Get() string
	Set(string)
}

String supports binding a string value.

func BoolToString added in v1.2.1

func BoolToString(v Bool) String

BoolToString creates a binding that connects a Bool data item to a String. Changes to the Bool will be pushed to the String and setting the string will parse and set the Bool if the parse was successful.

func BoolToStringWithFormat added in v1.2.1

func BoolToStringWithFormat(v Bool, format string) String

BoolToStringWithFormat creates a binding that connects a Bool data item to a String and is presented using the specified format. Changes to the Bool will be pushed to the String and setting the string will parse and set the Bool if the string matches the format and its parse was successful.

func FloatToString

func FloatToString(v Float) String

FloatToString creates a binding that connects a Float data item to a String. Changes to the Float will be pushed to the String and setting the string will parse and set the Float if the parse was successful.

func FloatToStringWithFormat

func FloatToStringWithFormat(v Float, format string) String

FloatToStringWithFormat creates a binding that connects a Float data item to a String and is presented using the specified format. Changes to the Float will be pushed to the String and setting the string will parse and set the Float if the string matches the format and its parse was successful.

func IntToString

func IntToString(v Int) String

IntToString creates a binding that connects a Int data item to a String. Changes to the Int will be pushed to the String and setting the string will parse and set the Int if the parse was successful.

func IntToStringWithFormat

func IntToStringWithFormat(v Int, format string) String

IntToStringWithFormat creates a binding that connects a Int data item to a String and is presented using the specified format. Changes to the Int will be pushed to the String and setting the string will parse and set the Int if the string matches the format and its parse was successful.

func NewString

func NewString() String

NewString returns a bindable string value that is managed internally.

type Struct added in v1.2.1

type Struct interface {
	DataMap
	GetValue(string) (interface{}, error)
	SetValue(string, interface{}) error
	Reload() error
}

Struct is the base interface for a bound struct type.

Since: 2.0

func BindStruct added in v1.2.1

func BindStruct(i interface{}) Struct

BindStruct creates a new map binding of string to interface{} using the struct passed as data. The key for each item is a string representation of each exported field with the value set as an interface{}. Only exported fields are included.

Since: 2.0

type Untyped

type Untyped interface {
	DataItem
	Get() interface{}
	Set(interface{})
}

Untyped supports binding a interface{} value.

func NewUntyped

func NewUntyped() Untyped

NewUntyped returns a bindable interface{} value that is managed internally.

type UntypedMap added in v1.2.1

type UntypedMap interface {
	DataMap
	Delete(string)
	Get() (map[string]interface{}, error)
	GetValue(string) (interface{}, error)
	Set(map[string]interface{}) error
	SetValue(string, interface{}) error
}

UntypedMap is a map data binding with all values Untyped (interface{}).

Since: 2.0

func NewUntypedMap added in v1.2.1

func NewUntypedMap() UntypedMap

NewUntypedMap creates a new, empty map binding of string to interface{}.

Since: 2.0

Jump to

Keyboard shortcuts

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