{"id":23534509,"url":"https://github.com/cyberbeni/typednotificationcenter","last_synced_at":"2025-10-19T06:34:15.373Z","repository":{"id":36111491,"uuid":"185042561","full_name":"Cyberbeni/TypedNotificationCenter","owner":"Cyberbeni","description":"Typed version of Apple's NotificationCenter to avoid forgetting setting parameters in the userInfo dictionary and needing to handle not having those parameters.","archived":false,"fork":false,"pushed_at":"2025-02-26T10:01:51.000Z","size":509,"stargazers_count":5,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-23T01:54:50.111Z","etag":null,"topics":["carthage","ios","linux","macos","swift"],"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/Cyberbeni.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2019-05-05T14:32:52.000Z","updated_at":"2024-09-28T22:36:22.000Z","dependencies_parsed_at":"2024-12-26T00:36:10.042Z","dependency_job_id":null,"html_url":"https://github.com/Cyberbeni/TypedNotificationCenter","commit_stats":{"total_commits":362,"total_committers":3,"mean_commits":"120.66666666666667","dds":0.3121546961325967,"last_synced_commit":"6e682f918c89cc769218e4f41059d3cea6ea7e14"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cyberbeni%2FTypedNotificationCenter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cyberbeni%2FTypedNotificationCenter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cyberbeni%2FTypedNotificationCenter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cyberbeni%2FTypedNotificationCenter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Cyberbeni","download_url":"https://codeload.github.com/Cyberbeni/TypedNotificationCenter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250354301,"owners_count":21416751,"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":["carthage","ios","linux","macos","swift"],"created_at":"2024-12-26T00:25:50.918Z","updated_at":"2025-10-19T06:34:10.349Z","avatar_url":"https://github.com/Cyberbeni.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TypedNotificationCenter\n\n[![Code coverage](https://codecov.io/github/Cyberbeni/TypedNotificationCenter/coverage.svg?branch=master)](https://codecov.io/github/Cyberbeni/TypedNotificationCenter?branch=master) [![codebeat badge](https://codebeat.co/badges/a94b1565-4033-4efb-b60b-76ba952ff4ad)](https://codebeat.co/projects/github-com-cyberbeni-typednotificationcenter-master) [![GitHub release](https://img.shields.io/github/release/Cyberbeni/TypedNotificationCenter.svg)](https://GitHub.com/Cyberbeni/TypedNotificationCenter/releases/)\n [![MIT Licence](https://badges.frapsoft.com/os/mit/mit.svg?v=103)](https://opensource.org/licenses/mit-license.php)\n\n ![Platforms](https://img.shields.io/badge/platform-iOS%20%7C%20Linux%20%7C%20macOS%20%7C%20tvOS%20%7C%20watchOS-lightgrey) [![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) [![Swift Package Manager Compatible](https://img.shields.io/badge/SwiftPM-compatible-4BC51D.svg?style=flat)](https://swift.org/package-manager/) [![CocoaPods Compatible](https://img.shields.io/badge/CocoaPods-compatible-4BC51D.svg?style=flat)](https://cocoapods.org/pods/TypedNotificationCenter) \n\nThis framework is about rethinking Apple's NotificationCenter to be more typesafe and about removing uncertainity of the needed value being present in the userInfo dictionary. It can be also used to handle NSNotification.Name subscriptions with better performance than NSNotificationCenter.\n\nIt is assumed that you already have (or at least know how to make) a DisposeBag-like system for keeping observations alive. (Observations are cleaned up when the observer token is deallocated)\n\n## Example usage\n\n### Typesafe API\n\n```swift\n// SampleNotification.swift\nimport TypedNotificationCenter\n\nenum SampleNotification: TypedNotification {\n    struct Payload {\n        let type = \"test\"\n    }\n    typealias Sender = MyCustomView\n}\n```\n\n```swift\n// OtherFile.swift\n// Observe a notification and execute a block with the sender and the payload\nvar observations = [TypedNotificationObservation]()\nobservations.append(TypedNotificationCenter.default.observe(SampleNotification.self, object: nil, block: { (sender, payload) in\n    print(sender, payload)\n}))\n\n// Post a notification\nTypedNotificationCenter.default.post(SampleNotification.self, sender: self, payload: SampleNotification.Payload())\n\n// Stop observing the notification, this is also called when the observation object deinitializes\nobservation?.invalidate()\n```\n\n### Typesafe bridging\n\n```swift\nenum KeyboardWillShowNotification: BridgedNotification {\n    public static var notificationName: Notification.Name = UIResponder.keyboardWillShowNotification\n    public typealias Sender = NSNull\n    public typealias Payload = KeyboardNotificationPayload\n}\n```\n\n### 1:1 drop-in replacement for existing NSNotificationCenter usage\n\n```swift\nvar observations = [TypedNotificationObservation]()\nobservations.append(TypedNotificationCenter.default.observe(NSLocale.currentLocaleDidChangeNotification, object: nil, queue: NSOperationQueue.mainQueue()) { notification in\n    print(\"The user's locale changed to: \\(NSLocale.currentLocale().localeIdentifier)\")\n})\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcyberbeni%2Ftypednotificationcenter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcyberbeni%2Ftypednotificationcenter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcyberbeni%2Ftypednotificationcenter/lists"}