A lightweight and customizable polling utility using Combine.
- β
Periodic event publishing using
Combine - β‘οΈ Optional immediate first fire (
fireImmediately) - π Easily start and stop polling
- π§ͺ Fully tested with
XCTest
Add the following to your Package.swift dependencies:
.package(url: "https://github.com/aligungor/Poller.git", from: "1.0.0")Then add "Poller" to your target dependencies:
.target(
name: "YourApp",
dependencies: [
.product(name: "Poller", package: "Poller")
]
)Or use Xcode:
File > Add Packages- Paste the URL of this repo
- Choose version and add
Pollerto your target
import Poller
import Combine
let poller = Poller(interval: 1.0, fireImmediately: true)
var cancellables = Set<AnyCancellable>()
poller.publisher
.sink {
print("Tick")
}
.store(in: &cancellables)
poller.start()
// Stop polling when needed
poller.stop()Sources/Pollerβ Core implementationTests/PollerTestsβ Unit tests
MIT License. See LICENSE file for details.