Skip to content

Commit

Permalink
fixed widget initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
exelban committed Sep 16, 2019
1 parent 3fb0eea commit 2a99888
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Stats/Modules/Battery/BatteryReader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,15 @@ class BatteryReader: Reader {

init() {
self.value = Observable([])
read()
self.updateInterval.subscribe(observer: self) { (value, _) in
self.stop()
self.start()
}
}

func start() {
read()

self.service = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("AppleSmartBattery"))
if updateTimer != nil {
return
Expand Down
3 changes: 2 additions & 1 deletion Stats/Modules/CPU/CPUReader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ class CPUReader: Reader {
if status != 0 {
numCPUs = 1
}
read()
}

self.updateInterval.subscribe(observer: self) { (value, _) in
Expand All @@ -66,6 +65,8 @@ class CPUReader: Reader {
}

func start() {
read()

if updateTimer != nil {
return
}
Expand Down
3 changes: 2 additions & 1 deletion Stats/Modules/Disk/DiskReader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ class DiskReader: Reader {

init() {
self.value = Observable([])
read()
self.updateInterval.subscribe(observer: self) { (value, _) in
self.stop()
self.start()
}
}

func start() {
read()

if updateTimer != nil {
return
}
Expand Down
4 changes: 2 additions & 2 deletions Stats/Modules/Memory/MemoryReader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ class MemoryReader: Reader {
print("Error with host_info(): " + (String(cString: mach_error_string(kerr), encoding: String.Encoding.ascii) ?? "unknown error"))
}

read()

self.updateInterval.subscribe(observer: self) { (value, _) in
self.stop()
self.start()
}
}

func start() {
read()

if updateTimer != nil {
return
}
Expand Down

0 comments on commit 2a99888

Please sign in to comment.