{"id":17437359,"url":"https://github.com/blixt/swift-empty-tuple","last_synced_at":"2026-01-22T14:59:52.572Z","repository":{"id":137380624,"uuid":"128197456","full_name":"blixt/swift-empty-tuple","owner":"blixt","description":"A journey through Swift versions as generics with the empty tuple becomes less powerful.","archived":false,"fork":false,"pushed_at":"2018-04-05T12:49:53.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"swift-3.0","last_synced_at":"2025-10-11T15:58:40.518Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/blixt.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-04-05T11:36:56.000Z","updated_at":"2018-04-05T12:49:55.000Z","dependencies_parsed_at":"2023-05-04T17:41:01.643Z","dependency_job_id":null,"html_url":"https://github.com/blixt/swift-empty-tuple","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/blixt/swift-empty-tuple","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blixt%2Fswift-empty-tuple","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blixt%2Fswift-empty-tuple/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blixt%2Fswift-empty-tuple/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blixt%2Fswift-empty-tuple/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/blixt","download_url":"https://codeload.github.com/blixt/swift-empty-tuple/tar.gz/refs/heads/swift-3.0","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blixt%2Fswift-empty-tuple/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28664827,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-22T14:01:31.714Z","status":"ssl_error","status_checked_at":"2026-01-22T13:59:23.143Z","response_time":144,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2024-10-17T11:54:43.169Z","updated_at":"2026-01-22T14:59:52.553Z","avatar_url":"https://github.com/blixt.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"This repository takes a look at a pattern that worked well\nin Swift 3, but has since become less and less powerful due\nto changes in both Swift 4.0 and Swift 4.1.\n\n\n## Quick links\n\n* [The actual code I am maintaining][real life]\n* [The distilled example (Swift 3.0)][swift 3.0]\n* [Changes necessary from 3.0 to 4.0][swift 3.0 to 4.0]\n* [Changes necessary from 4.0 to 4.1][swift 4.0 to 4.1]\n\n[real life]: https://github.com/blixt/swift-empty-tuple/blob/swift-3.0/event.swift\n[swift 3.0]: https://github.com/blixt/swift-empty-tuple/blob/swift-3.0/example.swift\n[swift 3.0 to 4.0]: https://github.com/blixt/swift-empty-tuple/compare/swift-3.0...swift-4.0\n[swift 4.0 to 4.1]: https://github.com/blixt/swift-empty-tuple/compare/swift-4.0...swift-4.1\n\n\n## Notes\n\nIn Swift 3.x, a tuple value could be used as an implicit stand-in for multiple\n(or zero) arguments. In Swift 4.0 this changed ([SE-0110][]) to require the\ntuple to be explicit except when the tuple/argument list is exactly 1 item.\n\nIn Swift 4.1 something else changed, so that functions called in a certain way\nnow no longer support tuples in place of arguments, even explicitly. Instead,\nonly a single argument must be provided, and the tuple values (if any) must\nbe accessed through indexed or named properties.\n\n[SE-0110]: https://github.com/apple/swift-evolution/blob/master/proposals/0110-distingish-single-tuple-arg.md\n\n\n## Usage of the Event class\n\nTo explain the purpose of the `Event` class, here’s an excerpt of its use:\n\n```swift\nclass ChatService {\n    static let instance = ChatService()\n\n    let connected = Event\u003cVoid\u003e()\n    let disconnected = Event\u003cVoid\u003e()\n    let joinedChannel = Event\u003cChannel\u003e()\n    let leftChannel = Event\u003cString\u003e()\n    let newMessage = Event\u003c(Channel, Channel.Entry)\u003e()\n    let participantsChanged = Event\u003cChannel\u003e()\n\n    // ...\n}\n```\n\nEmitting an event:\n\n```swift\nextension ChatService: WebSocketDelegate {\n    func websocketDidReceiveMessage(socket: WebSocketClient, text: String) {\n        guard let senderId = ..., let type = ..., let data = ... else {\n            NSLog(\"%@\", \"WARNING: Failed to parse message: \\(text)\")\n            return\n        }\n        switch type {\n        case \"join\":\n            guard let account = ..., let channel = ... else {\n                NSLog(\"%@\", \"WARNING: Got invalid join message: \\(data)\")\n                break\n            }\n            channel.accounts[senderId] = account\n            self.participantsChanged.emit(channel)  // \u003c---\n            print(\"--- @\\(account.username) joined #\\(channel.id)\")\n        case \"...\":\n            // ...\n        }\n    }\n\n    // ...\n}\n```\n\nHandling it:\n\n```swift\nclass ProfileViewController: UIViewController {\n    override func viewWillAppear(_ animated: Bool) {\n\tsuper.viewWillAppear(animated)\n        ChatService.instance.participantsChanged.addListener(self, method: ProfileViewController.handleParticipantsChanged)\n        // ...\n    }\n\n    override func viewWillDisappear(_ animated: Bool) {\n\tsuper.viewWillDisappear(animated)\n        ChatService.instance.participantsChanged.removeListener(self)\n        // ...\n    }\n\n    // ...\n\n    private func handleParticipantsChanged(channel: ChatService.Channel) {\n        guard channel.id == self.channelId else {\n            return\n        }\n        self.chatAccounts = channel.accounts\n        self.updateSegments()\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblixt%2Fswift-empty-tuple","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblixt%2Fswift-empty-tuple","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblixt%2Fswift-empty-tuple/lists"}