# Simplex Architecture

#### A Library of simple architectures that decouples state changes from SwiftUI's View.


[](https://github.com/Ryu0118/swiftui-simplex-architecture/releases/latest)
[](https://swiftpackageindex.com/Ryu0118/swiftui-simplex-architecture)
[](https://swiftpackageindex.com/Ryu0118/swiftui-simplex-architecture)
[](https://twitter.com/ryu_hu03)
This library is inspired by TCA ([swift-composable-architecture](https://github.com/pointfreeco/swift-composable-architecture)), which allows you to decouple the state change logic from the SwiftUI's View and ObservableObject and confine it within the Reducer.
In TCA, integrating child domains into parent domains resulted in higher computational costs, especially at the leaf nodes of the app. Our library addresses this by avoiding the integration of child domains into parent domains, eliminating unnecessary computational overhead. To share values or logic with deeply nested views, we leverage SwiftUI's EnvironmentObject property wrapper. This allows you to seamlessly write logic or state that can be accessed throughout the app. Moreover, our library simplifies the app-building process. You no longer need to remember various TCA modifiers or custom views like ForEachStore, IfLetStore, SwitchStore, sheet(store:), and so on.
## Examples
We've provided example implementations within this library. Currently, we only feature a simple GitHub repository search app, but we plan to expand with more examples in the future.
- [Github Repository Search App](https://github.com/Ryu0118/swiftui-simplex-architecture/tree/main/Examples/Github-App)
## Documentation
The documentation for main are available here:
- [main](https://ryu0118.github.io/swiftui-simplex-architecture/documentation/simplexarchitecture/)
## Installation
```Swift
let package = Package(
name: "YourProject",
...
dependencies: [
.package(url: "https://github.com/Ryu0118/swiftui-simplex-architecture", exact: "0.9.0")
],
targets: [
.target(
name: "YourTarget",
dependencies: [
.product(name: "SimplexArchitecture", package: "swiftui-simplex-architecture"),
]
)
]
)
```
## Basic Usage
The usage is almost the same as in TCA.
State definitions use property wrappers used in SwiftUI, such as `@State`, `@Binding`, `@FocusState.`
```Swift
@Reducer
struct MyReducer {
enum ViewAction {
case increment
case decrement
}
func reduce(into state: StateContainer