{"id":24527164,"url":"https://github.com/xtro/swiftmvi","last_synced_at":"2025-04-14T15:24:24.066Z","repository":{"id":65149516,"uuid":"582007923","full_name":"xtro/SwiftMVI","owner":"xtro","description":"A lightweight MVI framework for Swift","archived":false,"fork":false,"pushed_at":"2023-02-09T19:03:24.000Z","size":610,"stargazers_count":22,"open_issues_count":0,"forks_count":2,"subscribers_count":0,"default_branch":"main","last_synced_at":"2024-05-01T22:05:53.995Z","etag":null,"topics":["clean-architecture","combine","concurrency","concurrent-programming","framework","intent","mvi","mvi-architecture","state","swift","swift-package-manager","swift-packages","swift5","swiftui","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/xtro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":["xtro"]}},"created_at":"2022-12-25T09:24:50.000Z","updated_at":"2024-03-13T01:29:17.000Z","dependencies_parsed_at":"2025-01-22T06:27:08.323Z","dependency_job_id":null,"html_url":"https://github.com/xtro/SwiftMVI","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xtro%2FSwiftMVI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xtro%2FSwiftMVI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xtro%2FSwiftMVI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xtro%2FSwiftMVI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xtro","download_url":"https://codeload.github.com/xtro/SwiftMVI/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248905018,"owners_count":21180906,"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":["clean-architecture","combine","concurrency","concurrent-programming","framework","intent","mvi","mvi-architecture","state","swift","swift-package-manager","swift-packages","swift5","swiftui","unidirectional-data-flow"],"created_at":"2025-01-22T06:17:00.291Z","updated_at":"2025-04-14T15:24:24.020Z","avatar_url":"https://github.com/xtro.png","language":"Swift","readme":"![SwiftMVI Logo](./Documentation/SwiftMVI.docc/Resources/swiftmvi_icon_338@2x.png)\n# SwiftMVI\n\n\n[![Swift](https://github.com/xtro/SwiftMVI/actions/workflows/swift.yml/badge.svg?branch=main)](https://github.com/xtro/SwiftMVI/actions/workflows/swift.yml) ![platforms](https://img.shields.io/badge/platform-iOS%20%7C%20watchOS%20%7C%20tvOS%20%7C%20macOS-333333) [![Swift Package Manager compatible](https://img.shields.io/badge/Swift%20Package%20Manager-compatible-brightgreen.svg)](https://github.com/apple/swift-package-manager) ![GitHub](https://img.shields.io/github/license/xtro/SwiftMVI) ![Current version](https://img.shields.io/github/v/tag/xtro/SwiftMVI)\n\n**SwiftMVI** is an open-source library of conformables and extensions for swift, which provides an ability to build an MVI architecture with independent ``UseCases`` in SwiftUI.\n\n## Overview\n\n**SwiftMVI** provides the following features:\n- Lightweight \u0026 scalable: Wide range of possible implementations from a single reducer to complex feature with child modules.\n- Customizable workflows: You can build many variations by conform to ``Reducibles`` and ``Reducers``.\n- A simple but very effective API bind parts together, including your existing combine publishers.\n- Usable view protocols to implement your own feature driven view.\n\nThe main goal is a set of protocols for archiving structured data-flow with minimal effort.\nBut if you familiar with MVI architecture, there are some important differences compared to other MVI implementations:\n\n- a State can be reference or value type. The reducers mutating the actual state via `Processing`, using `state()` methods, and a reducer always returns Void, if you must to handle an effect use `effect()` method.\n- On the view side, you can choose between`ObservableObject` or `statePublisher` for updating.\n- Your existing Combine publishers can be connected using `bind` method to a ``Feature``, and a ``Feature`` can behave as a `Publisher`, when your feature comforms to `EventReducer`.\n\n## Installation\nYou can use Swift Package Manager to integrate the library by adding the following dependency in your Package.swift file or by adding directly within Xcode:\n\n```swift\n.package(url: \"https://github.com/xtro/SwiftMVI.git\", .upToNextMajor(from: \"0.2.0\"))\n```\n\n## Usage\n- [Example application](https://github.com/xtro/SwiftMVI-Examples)\n- [Getting Started](Documentation/SwiftMVI.docc/Getting_Started.md)\n- [Parts of SwiftMVI](Documentation/SwiftMVI.docc/Parts.md)\n\n### Example\n\nFeature:\n\n```swift\nclass CounterFeature: ReducibleState, IntentReducer, Processing {\n    var state: Int\n    var statePublisher: StatePublisher\n    \n    init(state: Int = 0) {\n        self.state = state\n        self.statePublisher = .init(state)\n    }\n    enum Intent {\n        case increment\n        case decrement\n    }\n    func reduce(intent: Intent) {\n        switch intent {\n        case .increment:\n            state {\n                $0 + 1\n            }\n        case .decrement:\n            state {\n                $0 - 1\n            }\n        }\n    }\n}\n```\n\nView:\n\n```swift\nstruct CounterView: FeatureView {\n    let feature: CounterFeature\n    \n    func body(_ newState: Int) -\u003e some View {\n        VStack {\n            HStack {\n                Button(\"−\") { feature(.decrement) }\n                Text(\"\\(newState)\")\n                Button(\"+\") { feature(.increment) }\n            }\n        }\n    }\n}\n```\n\n## Sponsors\nSwiftMVI is an MIT-licensed open-source project with its ongoing development made possible entirely by the support of awesome backers. If you'd like to join them, please consider sponsoring this development.\n\n## Contributing\nPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.\n\n## License\nThis library is released under the [MIT](https://choosealicense.com/licenses/mit/) license. See LICENSE for details.\n\n","funding_links":["https://github.com/sponsors/xtro"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxtro%2Fswiftmvi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxtro%2Fswiftmvi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxtro%2Fswiftmvi/lists"}