A simple short-polling center (crontab-like) with Swift 4.2
- Introduction
- Installation & Usage
- To do
This repo is a simple center for short-polling. You can easily manage repeating tasks with Swift. E.g. fetching APIs,...
- Add
PollingCenter.swift
to your project - Create your own polling. E.g.
class PrintPolling: NSObject, Pollingable {
func interval() -> Int {
return 5
}
// handler's called every interval time
func eventHandler() -> (() -> Void) {
return {
print("polling 1...")
}
}
}
- Add and enable your polling. E.g.
let pollingCenter = PollingCenter()
let printPolling = PrintPolling()
pollingCenter.addPolling(printPolling)
pollingCenter.enablePolling(printPolling.uid())
- Done. Now you can do whatever you want in
eventHandler
- Installing via Cocoapods
- Using Swift 5.x
- Delete pollings
- Enable/Disable all pollings
This project is licensed under the terms of the MIT license.