{"id":13695960,"url":"https://github.com/LeoMobileDeveloper/QTEventBus","last_synced_at":"2025-05-03T13:34:10.334Z","repository":{"id":55668495,"uuid":"140719126","full_name":"LeoMobileDeveloper/QTEventBus","owner":"LeoMobileDeveloper","description":"iOS事件总线，支持AppDelegate解耦，支持基于响应链的局部总线","archived":false,"fork":false,"pushed_at":"2020-12-14T06:09:24.000Z","size":202,"stargazers_count":428,"open_issues_count":2,"forks_count":69,"subscribers_count":10,"default_branch":"master","last_synced_at":"2024-10-18T22:38:51.043Z","etag":null,"topics":["appdelegate","eventbus","ios","module","notification","objective-c"],"latest_commit_sha":null,"homepage":"","language":"Objective-C","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/LeoMobileDeveloper.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-07-12T13:47:45.000Z","updated_at":"2024-08-25T16:29:51.000Z","dependencies_parsed_at":"2022-08-15T06:00:55.438Z","dependency_job_id":null,"html_url":"https://github.com/LeoMobileDeveloper/QTEventBus","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LeoMobileDeveloper%2FQTEventBus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LeoMobileDeveloper%2FQTEventBus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LeoMobileDeveloper%2FQTEventBus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LeoMobileDeveloper%2FQTEventBus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LeoMobileDeveloper","download_url":"https://codeload.github.com/LeoMobileDeveloper/QTEventBus/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224364491,"owners_count":17299081,"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":["appdelegate","eventbus","ios","module","notification","objective-c"],"created_at":"2024-08-02T18:00:35.084Z","updated_at":"2024-11-12T23:31:30.017Z","avatar_url":"https://github.com/LeoMobileDeveloper.png","language":"Objective-C","readme":"## QTEventBus\n\n[![Build Status](https://travis-ci.org/LeoMobileDeveloper/QTEventBus.svg)](https://travis-ci.org/LeoMobileDeveloper/QTEventBus)\n [![Version](https://img.shields.io/cocoapods/v/QTEventBus.svg?style=flat)](http://cocoapods.org/pods/QTEventBus)  [![Platform](http://img.shields.io/badge/platform-ios-blue.svg?style=flat\n)](https://developer.apple.com/iphone/index.action)\n [![License](http://img.shields.io/badge/license-MIT-lightgrey.svg?style=flat\n)](http://mit-license.org)\n\nQTEventBus是一个优雅的iOS事件总线，用来实现“发布-订阅”的消息通信模式。\n\n\u003cimg src=\"./images/event_bus_1.png\"\u003e\n\n- 支持强类型/弱类型\n- 自动取消订阅\n- 快速\n- 兼容`NSNotification`\n- 单元测试覆盖\n- 支持AppDelegate解耦\n- 支持基于响应链的局部总线\n\n文章：\n\n- [实现一个优雅的iOS消息总线](https://github.com/LeoMobileDeveloper/Blogs/blob/master/iOS/%E5%AE%9E%E7%8E%B0%E4%B8%80%E4%B8%AA%E4%BC%98%E9%9B%85%E7%9A%84iOS%E6%B6%88%E6%81%AF%E6%80%BB%E7%BA%BF.md)\n- [聊聊AppDelegate解耦](https://github.com/LeoMobileDeveloper/Blogs/blob/master/iOS/AppDelegate%E8%A7%A3%E8%80%A6.md)\n\n## 安装\n\n消息总线：\n\n```\npod QTEventBus\n```\n\nAppDelegate解耦：\n\n```\npod QTEventBus/AppModule\n```\n\n基于响应链的事件传递：\n\n```\npod QTEventBus/UIKit\n```\n\n## 系统要求\n\n- XCode 9 +\n- iOS 8+\n\n\n## 使用\n\n### 新建一个类作为事件，实现协议`QTEvent`\n\n```\n@interface QTLoginEvent : NSObject\u003cQTEvent\u003e\n@property (copy, nonatomic) NSString * userId; //可以携带任意数据\n@property (copy, nonatomic) NSString * userName; //可以携带任意数据\n@end\n```\n\n### 订阅这个事件\n\n\u003e QTSub(object,className)宏的作用是在object的生命周期内，订阅className事件，当object释放的时候自动取消订阅。\n\n```\n//注意eventBus会持有这个block，需要弱引用object\n[QTSub(self,QTLoginEvent) next:^(QTLoginEvent * event) {\n    NSLog(@\"%ld\",event.userId);\n}];\n```\n\n如果需要在主线程订阅，使用宏`QTSubMain`\n\n### 发布事件\n\n```\nQTLoginEvent * event;\n[QTEventBus.shared dispatch:event];\n```\n\n## 详细文档\n\n- [核心功能](./Doc/Basic.md)\n- [扩展：AppDelegate解耦](./Doc/Module.md)\n- [扩展：基于响应链的事件传递](./Doc/UIKitSupport.md)\n\n\n## 许可证\n\nQTEventBus使用 MIT 许可证，详情见 LICENSE 文件。\n","funding_links":[],"categories":["Foundation"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLeoMobileDeveloper%2FQTEventBus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FLeoMobileDeveloper%2FQTEventBus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLeoMobileDeveloper%2FQTEventBus/lists"}