{"id":30416855,"url":"https://github.com/manolofdez/reducedispatcher","last_synced_at":"2025-10-15T12:24:58.510Z","repository":{"id":243572120,"uuid":"812786598","full_name":"manolofdez/ReduceDispatcher","owner":"manolofdez","description":"TCA macro for routing Actions to function calls.","archived":false,"fork":false,"pushed_at":"2024-06-12T03:29:27.000Z","size":43,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-06-13T04:31:40.355Z","etag":null,"topics":["composable-architecture","ios","macros","swift","tca"],"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/manolofdez.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-09T21:48:04.000Z","updated_at":"2024-06-13T04:31:40.356Z","dependencies_parsed_at":"2024-06-10T23:40:46.845Z","dependency_job_id":null,"html_url":"https://github.com/manolofdez/ReduceDispatcher","commit_stats":null,"previous_names":["manolofdez/reducedispatcher"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/manolofdez/ReduceDispatcher","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manolofdez%2FReduceDispatcher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manolofdez%2FReduceDispatcher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manolofdez%2FReduceDispatcher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manolofdez%2FReduceDispatcher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/manolofdez","download_url":"https://codeload.github.com/manolofdez/ReduceDispatcher/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manolofdez%2FReduceDispatcher/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271588743,"owners_count":24785751,"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","status":"online","status_checked_at":"2025-08-22T02:00:08.480Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["composable-architecture","ios","macros","swift","tca"],"created_at":"2025-08-22T05:10:21.380Z","updated_at":"2025-10-15T12:24:53.431Z","avatar_url":"https://github.com/manolofdez.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ReduceDispatcher\nA [Composable Architecture](https://github.com/pointfreeco/swift-composable-architecture) companion \nmacro that generates the boilerplate necessary for routing a Reducer's Actions to function calls.\n\n## Motivation\nTCA is awesome! State management, testability, what's not to like!? That said, I often find \nmyself a bit lost with all the enum cases, specifically in the Reducer's body. And while we can \nalways split reducers up, sometimes there isn't a clean way of divvying up its responsibilities \nin a way that alleviates the problem.\n\nWhat's causing this sense of disorientation? Is it the extra indentation? Is it the way each case \nis separated from one another? (Is it just me?) I don't know. To get to the bottom of this, we need \nto play around with some ideas! \n\nThe `ReduceDispatcher` project explores one such idea: what if we could _hide_ the Reduce's switch \nstatement while retaining all the pieces and concepts of TCA? Would it _feel_ better if we replaced \nall enum cases in a Reducer's body with function calls?\n\nWell, let's find out!\n\n## Usage\n\nSetting up the dispatcher is simple, though not entirely automatic. Take the following reducer:\n\n```swift\n@Reducer\nstruct MyReducer {\n    \n    struct State {}\n    \n    enum Action {\n        case didAppear\n    }\n    \n    var body: some ReducerOf\u003cSelf\u003e {\n        Reduce { _, action in\n            switch action {\n            case .didAppear:\n                print(\"foo\")\n            }\n            return .none \n        }\n    }\n}\n```\n\nAll you need to do is:\n\n1. Import the `ReduceDispatcher` package\n2. Add the `ReduceDispatcher` annotation\n3. Replace `Reduce { ...` with `Dispatch(self)`\n4. Conform your reducer to the autogenerated reducer\n  - The name is the name of your reducer, suffixed with `ActionDelegate`\n  - Don't worry if this doesn't make sense. If you follow the previous \n    step, the compiler will yell and tell you what to do.\n\n```swift\nimport ReduceDispatcher\n\n@Reducer\n@ReduceDispatcher\nstruct MyReducer {\n    \n    struct State {}\n    \n    enum Action {\n        case didAppear\n    }\n    \n    var body: some ReducerOf\u003cSelf\u003e {\n        Dispatch(self)\n    }\n}\n\nextension MyReducer: MyReducerActionDelegate {\n    func didAppear(state: inout State) -\u003e Effect\u003cAction\u003e {\n        print(\"foo\")\n        return .none\n    }\n}\n```\n\nThat's it!\n\n### Dispatch skipping\n\nSometimes you're scoping a bunch of child reducers, or are treating some actions as events. Having to \nwrite out a function for those just to return `.none` feels so bad, right? We gotchu! Just use the \n`@SkipDispatch` macro. Like so:\n\n```swift\nimport ReduceDispatcher\n\n@Reducer\n@ReduceDispatcher\nstruct MyReducer {\n    \n    struct State {}\n    \n    enum Action {\n        case didAppear\n        @SkipDispatch\n        case didDisappear\n    }\n    \n    var body: some ReducerOf\u003cSelf\u003e {\n        Dispatch(self)\n    }\n}\n```\n\n## Installation\n\n### Swift Package Manager\n\nThis library can be installed using the Swift Package Manager by adding it to your Package Dependencies.\n\n## Requirements\n\n- iOS 16.0+\n- MacOS 13.0+\n- Swift 5\n- Xcoce 15.4+\n\n## License\n\nLicensed under MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmanolofdez%2Freducedispatcher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmanolofdez%2Freducedispatcher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmanolofdez%2Freducedispatcher/lists"}