Issue #375
final class LifecyclerHandler {
private var observer: AnyObject!
var action: (() -> Void)?
private let debouncer = Debouncer(delay: 1.0)
func setup() {
observer = NotificationCenter.default.addObserver(
forName: UIApplication.didBecomeActiveNotification,
object: nil,
queue: .main,
using: { [weak self] _ in
self?.debouncer.run {
self?.action?()
}
})
}
}
private let lifecycleHandler = LifecyclerHandler()
override func viewDidLoad() {
super.viewDidLoad()
lifecycleHandler.action = {
Deps.userHandler.refreshToken()
}
lifecycleHandler.setup()
}