- ✍️ Description
- 🖥 Example
- 🎟 Demo
- 💻 How to use
⚠️ Requirements- 💪 Contribute
The PollingController
does the timed long-term polling for you and takes care that only one async operation is open at a time. If the async operation takes more time than the timer interval, it waits until the callback is invoked to continue.
import PollingKit
let pollingController = PollingController(preferredInterval: 5) { callback in
// Imagine an API call being made here.
loadSomethingAsynchronously() {
callback()
}
}
This demo shows how the PollingController
switches states.
You can find this demo app in this repository.
Cocoapods:
PollingKit
is available on Cocoapods. Just put following line in your Podfile
:
pod 'PollingKit'
Swift Package Manager:
Add the following to your Package.swift
file:
dependencies: [
.package(url: "https://github.com/lukaswuerzburger/PollingKit.git", from: "2.0.0")
]
- Swift 5+
- iOS 10+
- Xcode 13+
Issues and pull requests are welcome.