{"id":16686408,"url":"https://github.com/wickwirew/sideeffects","last_synced_at":"2025-04-10T00:16:26.369Z","repository":{"id":243147319,"uuid":"164521228","full_name":"wickwirew/SideEffects","owner":"wickwirew","description":"A µFramework for handling side effects in a Redux ReSwift applcation.","archived":false,"fork":false,"pushed_at":"2019-02-24T23:15:30.000Z","size":27,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-10T00:16:20.482Z","etag":null,"topics":["ios","middleware","redux","reswift","swift","unidirectional-data-flow"],"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/wickwirew.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":"2019-01-08T00:38:08.000Z","updated_at":"2023-04-05T10:49:05.000Z","dependencies_parsed_at":"2024-06-07T01:06:27.747Z","dependency_job_id":null,"html_url":"https://github.com/wickwirew/SideEffects","commit_stats":null,"previous_names":["wickwirew/sideeffects"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wickwirew%2FSideEffects","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wickwirew%2FSideEffects/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wickwirew%2FSideEffects/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wickwirew%2FSideEffects/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wickwirew","download_url":"https://codeload.github.com/wickwirew/SideEffects/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248131315,"owners_count":21052819,"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":["ios","middleware","redux","reswift","swift","unidirectional-data-flow"],"created_at":"2024-10-12T15:05:52.622Z","updated_at":"2025-04-10T00:16:26.348Z","avatar_url":"https://github.com/wickwirew.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SideEffects\nA µFramework for handling side effects in a Redux [ReSwift](https://www.github.com/ReSwift/ReSwift) applcation.\n\nThere are a lot of ways to manage side effects in a Redux application. Anything from using Thunks, Sagas, Observables and more. This is a different take on it from the normal approaches that plays to Swift's strengths, while taking inspiration from [redux-observables](https://github.com/redux-observable/redux-observable) and [ngrx effects](https://github.com/ngrx/effects) but without the `rx` part. The goal of `SideEffect`s is to allow you to easiliy, and declaritivly define a function that runs anytime an `Action` of a defined type is dispatched. Allowing your views to dispatch vanilla Redux actions and be completely agnostic to any side effects.\n\n## Usage\nFor example if you have an action `ItemSelected` that is dispatch when ever an item is selected from a list.\nWhen its fired you might want to call an API to load the record from the database.\n```swift\nSideEffect(of: ItemSelected.self) { action, state, dispatch in\n    api.loadRecord(id: action.id) { response\n        // using the dispatch function you can dispatch a success/failure action.\n    }\n}\n```\nThere can also be multiple `SideEffect`s defined per action. So to coninute on the previous example, if you also wanted to display the item's view controller as well. I could define another `SideEffect` to do so.\n```swift\nSideEffect(of: ItemSelected.self) { action, state, dispatch in\n    dispatch(SetRouteAction(...))\n}\n```\n\n## Setup\nFirstly, for ease of use first create a typealias for your application state's SideEffects.\n```swift\ntypealias SideEffect = Store\u003cAppState\u003e.SideEffect\n```\nThen define your applications SideEffects. The amount of SideEffects in the application can add up quick. For ease of organization it is recommended to separate them into multiple lists like so:\n```swift\nlet mySideEffects: [SideEffect] = [\n    SideEffect(of: ItemSelected.self) { ... },\n    SideEffect(of: AnotherAction.self) { ... },\n]\n```\nThen create the middleware and add it to the `store`\n```swift\ncreateSideEffectMiddleware(effects: mySideEffects + moreSideEffects)\n```\nAnd thats it! 🎉\n\n## Installation\n### Carthage\nYou can install SideEffects via Carthage by adding the following line to your `Cartfile`:\n```\ngithub \"wickwirew/SideEffects\"\n```\n### CocoaPods\n\nYou can install SideEffects via CocoaPods by adding the following line to your `Podfile`:\n```\npod 'SideEffects'\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwickwirew%2Fsideeffects","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwickwirew%2Fsideeffects","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwickwirew%2Fsideeffects/lists"}