Swiftpack.co - PerfectlySoft/Perfect-Repeater as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by PerfectlySoft.
PerfectlySoft/Perfect-Repeater 1.1.0
A simple library that takes a closure and executes it at the specified interval until the closure returns false or the application is terminated.
⭐️ 5
🕓 4 years ago
linux macOS iOS
.package(url: "https://github.com/PerfectlySoft/Perfect-Repeater.git", from: "1.1.0")

Perfect Repeater

Get Involed with Perfect!

Star Perfect On Github Stack Overflow Follow Perfect on Twitter Join the Perfect Slack

Swift 4.0 Platforms OS X | Linux License Apache PerfectlySoft Twitter Slack Status

The Perfect "Repeater" is a simple library that takes a closure and executes it at the specified interval until the closure returns false or the application is terminated.

Note that a demo is located at https://github.com/PerfectExamples/Perfect-Repeater-Demo that shows the operation of the library.

Compatibility with Swift

The master branch of this project currently compiles with Xcode 9 or the Swift 4 toolchain on Ubuntu, and is compatible with both Perfect 2.x and 3.x

Building

Add this project as a dependency in your Package.swift file.

.Package(url:"https://github.com/PerfectlySoft/Perfect-Repeater.git", majorVersion: 1)

Usage

Include in your file the import statement:

import PerfectRepeater

The base form of executing this is:

Repeater.exec(timer: <Double>, callback: <Closure>)

To demonstrate the process of repeating a closure containing your code and optionally re-queuing:

var opt = 1

let c = {
	() -> Bool in
	print("XXXXXX")
	return true
}
let cc = {
	() -> Bool in
	print("Hello, world! (\(opt))")
	if opt < 10 {
		opt += 1
		return true
	} else {
		print("cc exiting.")
		return false
	}
}

Repeater.exec(timer: 3.0, callback: c)
Repeater.exec(timer: 2.0, callback: cc)

Further Information

For more information on the Perfect project, please visit perfect.org.

GitHub

link
Stars: 5
Last commit: 4 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics