{"id":17977935,"url":"https://github.com/coderyi/actionstage","last_synced_at":"2025-03-25T16:31:10.947Z","repository":{"id":56901501,"uuid":"208690748","full_name":"coderyi/ActionStage","owner":"coderyi","description":"ActionStage that dispatch message, decoupling between modules","archived":false,"fork":false,"pushed_at":"2019-09-20T08:35:08.000Z","size":180,"stargazers_count":30,"open_issues_count":1,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-20T13:32:40.582Z","etag":null,"topics":["actionstage","actor","decouples","message","watcher"],"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/coderyi.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":"2019-09-16T02:14:21.000Z","updated_at":"2025-02-19T23:06:33.000Z","dependencies_parsed_at":"2022-08-20T18:10:08.959Z","dependency_job_id":null,"html_url":"https://github.com/coderyi/ActionStage","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderyi%2FActionStage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderyi%2FActionStage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderyi%2FActionStage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderyi%2FActionStage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coderyi","download_url":"https://codeload.github.com/coderyi/ActionStage/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245500116,"owners_count":20625506,"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":["actionstage","actor","decouples","message","watcher"],"created_at":"2024-10-29T17:30:13.111Z","updated_at":"2025-03-25T16:31:10.626Z","avatar_url":"https://github.com/coderyi.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ActionStage\n\n\n\n\n\n\nActionStage 来自于 Telegram 官方开源的 iOS 客户端。\n\nActionStage 是一个消息通信、模块解耦的框架。\n\nActionStage，消息的中枢派发模块\n\nActor，处理 requestActor 的模块\n\nWatcher，观察协议，定义为接收 ActionStage 的消息\n\nHandle，定义为管理 Watcher，给 Watcher 发消息的模块\n\n设计图如下\n\n![](https://github.com/coderyi/ActionStage/blob/master/ActionStage.jpg)\n\n## Installation\n\n```ruby\npod 'ActionStage'\n```\n\n## Example\n\n在 Example 文件夹下运行`pod install` \n\n## Usage\n\n\n### dispatchResource\n\ndispatchResource 类似于通知，\n\n发送消息\n\n```\n[ActionStageInstance() dispatchResource:@\"/as/unreadMessageCount\" resource:[[NSNumber alloc] initWithInt:2]];\n```\n\n监听对应 path，在回调可以接收消息\n\n```\n_actionHandle = [[ASHandle alloc] initWithDelegate:self releaseOnMainThread:true];\n\n[ActionStageInstance() watchForPaths:@[\n                                       @\"/as/unreadMessageCount\",\n                                       ] watcher:self];\n\n- (void)actionStageResourceDispatched:(NSString *)path resource:(id)resource arguments:(id)arguments;\n{\n    NSLog(@\"ResourceDispatch %@ %@\", path, resource);\n}\n```\n\n### requestActor\n\nrequestActor\n\n```\n[ActionStageInstance() requestActor:@\"/as/service/auth/sendCode\" options:[[NSDictionary alloc] initWithObjectsAndKeys:@\"123\", @\"phoneNumber\", nil] watcher:self];\n```\n\n这时可以定义一个 Actor 处理 sendCode 的网络任务，如 ASTestSendCodeRequestActor\n\n```\n+ (NSString *)genericPath\n{\n    return @\"/as/service/auth/sendCode\";\n}\n\n- (void)execute:(NSDictionary *)options\n{\n    NSString *phoneNumber = [options objectForKey:@\"phoneNumber\"];\n    [self sendNetwork:phoneNumber];\n}\n\n- (void)sendNetwork:(NSString *)phoneNumber\n{\n    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{\n        [ActionStageInstance() actionCompleted:self.path result:nil];\n    });\n}\n```\n\n\n### actionCompleted\n\n当 Actor 执行完成后，可以发起 actionCompleted\n\n```\n[ActionStageInstance() actionCompleted:self.path result:nil];\n```\n\n在 Watcher 可以接收到消息\n\n```\n- (void)actorCompleted:(int)resultCode path:(NSString *)path result:(id)result\n{\n    NSLog(@\"requestActor completed %@\",path);\n}\n```\n\n\n## Author\n\ncoderyi, coderyi@foxmail.com\n\n## License\n\nActionStage is available under the MIT license. See the LICENSE file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoderyi%2Factionstage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoderyi%2Factionstage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoderyi%2Factionstage/lists"}