{"id":17046197,"url":"https://github.com/ladislas/swifteventcenter","last_synced_at":"2025-03-23T03:18:42.646Z","repository":{"id":62456462,"uuid":"150266997","full_name":"ladislas/SwiftEventCenter","owner":"ladislas","description":"A simple and easy to use event manager","archived":false,"fork":false,"pushed_at":"2018-10-17T11:21:27.000Z","size":185,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"develop","last_synced_at":"2025-02-28T15:11:07.938Z","etag":null,"topics":["cocoapods","event","notification","nsnotificationcenter","observer-pattern","spm","swift","swift-package-manager"],"latest_commit_sha":null,"homepage":"https://ladislas.github.io/SwiftEventCenter/","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ladislas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-09-25T13:09:08.000Z","updated_at":"2019-12-04T03:04:30.000Z","dependencies_parsed_at":"2022-11-02T00:15:15.891Z","dependency_job_id":null,"html_url":"https://github.com/ladislas/SwiftEventCenter","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ladislas%2FSwiftEventCenter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ladislas%2FSwiftEventCenter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ladislas%2FSwiftEventCenter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ladislas%2FSwiftEventCenter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ladislas","download_url":"https://codeload.github.com/ladislas/SwiftEventCenter/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245048610,"owners_count":20552542,"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":["cocoapods","event","notification","nsnotificationcenter","observer-pattern","spm","swift","swift-package-manager"],"created_at":"2024-10-14T09:45:34.894Z","updated_at":"2025-03-23T03:18:42.628Z","avatar_url":"https://github.com/ladislas.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Swift Event Center\n\n[![swift-version](https://img.shields.io/badge/Swift-4.2-orange.svg?style=flat)](swift.org)\n[![spm](https://img.shields.io/badge/spm-v1.1.1-blue.svg)](https://github.com/apple/swift-package-manager)\n[![CocoaPods](https://img.shields.io/cocoapods/v/SwiftEventCenter.svg)](https://cocoapods.org/pods/SwiftEventCenter)\n[![Build Status](https://travis-ci.org/ladislas/SwiftEventCenter.svg)](https://travis-ci.org/ladislas/SwiftEventCenter)\n[![SonarCloud](https://sonarcloud.io/api/project_badges/measure?project=ladislas_SwiftEventCenter\u0026metric=alert_status)](https://sonarcloud.io/dashboard?id=ladislas_SwiftEventCenter)\n[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=ladislas_SwiftEventCenter\u0026metric=coverage)](https://sonarcloud.io/dashboard?id=ladislas_SwiftEventCenter)\n[![SwiftEventCenter](https://img.shields.io/badge/license-Apache--2.0-lightgrey.svg)](https://github.com/ladislas/SwiftEventCenter/blob/master/LICENSE)\n\n## About\n\nSwift Event Center to create custom events and respond to them.\n\nThe idea was to build a simple event center from scratch to:\n\n- better understand how a notification/event center would work\n- have simple event manager for simple tasks\n- in pure Swift\n- and not use Apple's Notification Center\n\nThe interesting thing about the process is that while building it, I got a deeper understanding of how Notification Center.\n\nTo make it easier for new comers, I decided to keep Apple's way of naming things.\n\n**Note:** EventCenter is not meant to be a full replacement of Notification Center. It is a simpler alternative (as in \"*simpler to use, but also simpler in terms of functionalities*\") that should be good enough for *simple projects*.\n\n### Features\n\nEventCenter allows you to:\n\n- [x] - add observer for `Event.Name` (a.k.a. `Notification.Name`)\n- [x] - specify a name for added observers so that they can be removed independently\n- [x] - remove all observers for a specific `Event.Name`\n- [x] - remove one observer with a specific `name` for a specific `Event.Name`\n- [x] - post events and pass `object:Any?` \u0026 `userInfo:[AnyHashable:Any]?` \n- [ ] - specify priority for each observer (**not implemented yet**)\n\n\n## Installation\n\nWith SPM, add the following to the dependencies of your `Package.swift`\n\n```swift\n.package(url: \"https://github.com/ladislas/SwiftEventCenter\", from: \"1.1.1\")\n```\n\n\n## Usage\n\n`Event` is just a `typealias` for `Notification`.\n\nSee [docs](./docs), [Examples](./Examples) \u0026 [Tests](./Tests) for more information.\n\n```swift\nimport EventCenter\n\nlet ec = EventCenter()\n\n...\n\nec.addObserver(forEvent: Event.Name(\"event1\"), name: \"obs1\", callback: { event: Event in \n\n\tif let obj = event.object {\n\t\tprint(\"Hello, \\(obj)!\")\t\n\t}\n\n})\n\n...\n\nec.post(event: Event.Name(\"event1\"), object: \"World\")\n```\n\n## Authors\n\nMade with ❤️ by:\n\n- **Ladislas de Toldi** - [ladislas](https://github.com/ladislas)\n\n## License\n\nApache 2.0 @ Ladislas de Toldi\n\n**Original Work**\n\n*This project is based on great people's ideas. The original idea was created by [Stephen Haney](https://github.com/StephenHaney/Swift-Custom-Events). It was then improved by [Robin Walter](https://github.com/robinwalterfit)'s [Swift-Events](https://github.com/robinwalterfit/Swift-Events). First I wanted to fork Robin's repo but after spending a couple of hours on it, I decided to rewrite most of it. Original work from [Stephen Haney](https://github.com/StephenHaney) \u0026 [Robin Walter](https://github.com/robinwalterfit) is under MIT.*\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fladislas%2Fswifteventcenter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fladislas%2Fswifteventcenter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fladislas%2Fswifteventcenter/lists"}