[ios] Rewrote RatingSummaryView update.

This commit is contained in:
VladiMihaylenko 2017-12-06 18:21:27 +03:00 committed by Ilya Grechuhin
parent 8fbab9754b
commit 28edc6a30d
2 changed files with 6 additions and 10 deletions

View file

@ -183,6 +183,8 @@ import UIKit
}
}
var scheduledUpdate: DispatchWorkItem?
var settings = RatingSummaryViewSettings() {
didSet {
update()
@ -228,16 +230,10 @@ import UIKit
frame.size = intrinsicContentSize
}
@objc func doUpdate() {
DispatchQueue.main.async {
self.updateImpl()
}
}
func update() {
let sel = #selector(doUpdate)
NSObject.cancelPreviousPerformRequests(withTarget: self, selector: sel, object: nil)
perform(sel, with: nil, afterDelay: 1 / 120)
scheduledUpdate?.cancel()
scheduledUpdate = DispatchWorkItem { [weak self] in self?.updateImpl() }
DispatchQueue.main.async(execute: scheduledUpdate!)
}
override var intrinsicContentSize: CGSize {

View file

@ -322,7 +322,7 @@ import UIKit
func update() {
scheduledUpdate?.cancel()
scheduledUpdate = DispatchWorkItem { self.updateImpl() }
scheduledUpdate = DispatchWorkItem { [weak self] in self?.updateImpl() }
DispatchQueue.main.async(execute: scheduledUpdate!)
}