on self.addObserver(newSuperview) of ESRefreshComponent
open override func willMove(toSuperview newSuperview: UIView?) {
super.willMove(toSuperview: newSuperview)
/// Remove observer from superview immediately
self.removeObserver()
DispatchQueue.main.async { [unowned self, newSuperview] in
/// Add observer to new superview in next runloop
self.addObserver(newSuperview)
}
}
Xcode 9 / Swift 4
on self.addObserver(newSuperview) of ESRefreshComponent