Skip to content

Commit

Permalink
Merge pull request #2 from contactless/feature/lazy_init_controls
Browse files Browse the repository at this point in the history
Add ability to create controls with lazy initialization
  • Loading branch information
evgeny-boger authored Feb 21, 2020
2 parents 1420051 + 51d497d commit cd4e6c6
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions control.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ type ControlArgs interface {
SetRawValue(string) ControlArgs
SetValue(interface{}) ControlArgs
SetDoLoadPrevious(bool) ControlArgs
// SetLazyInit sets lazyInit flag to control
// If true - control will not create topic in mqtt before once explicitly set value to this control
// It also means that storage will be not used to store or restore values at all
SetLazyInit(bool) ControlArgs

GetDevice() Device
GetID() *string
Expand All @@ -33,6 +37,7 @@ type ControlArgs interface {
GetRawValue() *string
GetValue() interface{}
GetDoLoadPrevious() *bool
GetLazyInit() *bool
}

// Control is a user representation of MQTT device control
Expand Down Expand Up @@ -68,6 +73,7 @@ type Control interface {
GetOrder() int // Gets control order (or -1 for auto) (/meta/order)
GetValue() (interface{}, error) // Gets control value (converted according to type)
GetRawValue() string // Gets control value string
GetLazyInit() bool // Gets control lazyInit flag

// generic setters
SetDescription(desc string) FuncError
Expand All @@ -78,6 +84,10 @@ type Control interface {
SetMax(max int) FuncError
SetError(e ControlError) FuncError
SetOrder(ord int) FuncError
// SetLazyInit sets lazyInit flag to control
// If true - control will not create topic in mqtt before once explicitly set value to this control
// It also means that storage will be not used to store or restore values at all
SetLazyInit(bool) FuncError

// universal interface for UpdateValue and SetOnValue
SetValue(val interface{}) FuncError
Expand Down

0 comments on commit cd4e6c6

Please sign in to comment.