Swiftpack.co - bscothern/Once as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by bscothern.
bscothern/Once v1.3.3
A replacement for Dispatch Once in Swift
⭐️ 50
🕓 3 years ago
.package(url: "https://github.com/bscothern/Once.git", from: "v1.3.3")

Once

GitHub license SPM Carthage compatible

A simple thread safe replacement for Dispatch Once and pthread_once for Swift.

Swift Package Manager

Update your Package.swift to include the appropriate dependency below:

Swift 5.2+

.package(name: "Once", "https://github.com/bscothern/Once.git", from: "1.4.0")

Swift 4.0-5.1

.package(url: "https://github.com/bscothern/Once.git", from: "1.3.2")

Carthage Usage

Include this line in your Cartfile:

github "bscothern/Once"

Usage

import Once

let once = Once()

func foo() {
    once.runOnce {
        // Do stuff that should only execute the first time foo() is called.
    }
    // Do stuff
}

GitHub

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

Release Notes

v1.3.3
3 years ago

Cleaned up some formatting. Cleaned up pointer operations. Added a concurrent operations test.

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