{"id":13995339,"url":"https://github.com/bscothern/Once","last_synced_at":"2025-07-22T21:32:36.525Z","repository":{"id":93355050,"uuid":"106645559","full_name":"bscothern/Once","owner":"bscothern","description":"A replacement for Dispatch Once in Swift","archived":false,"fork":false,"pushed_at":"2021-01-07T04:38:02.000Z","size":45,"stargazers_count":50,"open_issues_count":0,"forks_count":6,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-08-10T14:19:01.961Z","etag":null,"topics":["c","carthage","dispatch","swift","swift-package-manager","swiftpm"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bscothern.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-10-12T04:43:53.000Z","updated_at":"2023-10-13T11:21:50.000Z","dependencies_parsed_at":"2023-03-21T14:04:06.112Z","dependency_job_id":null,"html_url":"https://github.com/bscothern/Once","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bscothern%2FOnce","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bscothern%2FOnce/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bscothern%2FOnce/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bscothern%2FOnce/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bscothern","download_url":"https://codeload.github.com/bscothern/Once/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227177907,"owners_count":17743198,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","carthage","dispatch","swift","swift-package-manager","swiftpm"],"created_at":"2024-08-09T14:03:21.380Z","updated_at":"2024-11-29T17:31:30.770Z","avatar_url":"https://github.com/bscothern.png","language":"Swift","funding_links":[],"categories":["Swift"],"sub_categories":[],"readme":"# Once\n\n[![GitHub license](https://img.shields.io/badge/license-MIT-lightgrey.svg)](https://raw.githubusercontent.com/Carthage/Carthage/master/LICENSE.md) [![SPM](https://img.shields.io/badge/spm-compatible-brightgreen.svg?style=flat)](https://swift.org/package-manager) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n\nA simple thread safe replacement for Dispatch Once and pthread_once for Swift.\n\n## Swift Package Manager\nUpdate your `Package.swift` to include the appropriate dependency below:\n\n### Swift 5.2+\n```swift\n.package(name: \"Once\", \"https://github.com/bscothern/Once.git\", from: \"1.4.0\")\n```\n\n### Swift 4.0-5.1\n```swift\n.package(url: \"https://github.com/bscothern/Once.git\", from: \"1.3.2\")\n```\n\n## Carthage Usage\nInclude this line in your `Cartfile`:\n```\ngithub \"bscothern/Once\"\n```\n\n## Usage\n```swift\nimport Once\n\nlet once = Once()\n\nfunc foo() {\n    once.runOnce {\n        // Do stuff that should only execute the first time foo() is called.\n    }\n    // Do stuff\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbscothern%2FOnce","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbscothern%2FOnce","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbscothern%2FOnce/lists"}