1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Better naming for some of the core interfaces

This commit is contained in:
Chris Cummer 2019-07-17 07:11:43 -07:00
parent 7ddf4a566d
commit e593a0d007
4 changed files with 16 additions and 12 deletions

9
wtf/enablable.go Normal file
View File

@ -0,0 +1,9 @@
package wtf
// Enablable is the interface that enforces enable/disable capabilities on a module
type Enablable interface {
Disabled() bool
Enabled() bool
Disable()
}

View File

@ -1,8 +0,0 @@
package wtf
type Enabler interface {
Disabled() bool
Enabled() bool
Disable()
}

View File

@ -4,14 +4,16 @@ import (
"time"
)
type Scheduler interface {
// Schedulable is the interface that enforces scheduling capabilities on a module
type Schedulable interface {
Refresh()
Refreshing() bool
RefreshInterval() int
}
// Schedule kicks off the first refresh of a module's data and then queues the rest of the
// data refreshes on a timer
func Schedule(widget Wtfable) {
// Kick off the first refresh and then leave the rest to the timer
widget.Refresh()
interval := time.Duration(widget.RefreshInterval()) * time.Second

View File

@ -6,9 +6,10 @@ import (
"github.com/rivo/tview"
)
// Wtfable is the interface that enforces WTF system capabilities on a module
type Wtfable interface {
Enabler
Scheduler
Enablable
Schedulable
BorderColor() string
ConfigText() string