Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mkj-is/elementarycombine
Experimental, uni-directional and purely functional architecture for SwiftUI.
https://github.com/mkj-is/elementarycombine
combine elm-architecture redux swift swiftui unidirectional-data-flow
Last synced: about 1 month ago
JSON representation
Experimental, uni-directional and purely functional architecture for SwiftUI.
- Host: GitHub
- URL: https://github.com/mkj-is/elementarycombine
- Owner: mkj-is
- License: mit
- Created: 2019-11-07T20:57:36.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2020-06-14T18:31:22.000Z (over 4 years ago)
- Last Synced: 2024-12-20T18:08:53.460Z (about 2 months ago)
- Topics: combine, elm-architecture, redux, swift, swiftui, unidirectional-data-flow
- Language: Swift
- Homepage:
- Size: 19.5 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# ElementaryCombine
[**Elementary**](https://github.com/mkj-is/Elementary) uni-directional architecture extension.
This package provides `ObservableStore` which can be easily used
in SwiftUI apps (but not exclusively).## Installation
When using Swift package manager install using Xcode 11+ or add following line to your dependencies:
```swift
.package(url: "https://github.com/mkj-is/ElementaryCombine.git", from: "0.1.0")
```## Usage
The `ObservableStore` builds on top of Elementary `Store` and adds conformance
to `ObservableObject` in Combine. Due to this fact it can ve easily connected
to SwiftUI views. See the following example of incrementing counter:```swift
struct RootView: View {
@ObservedObject var store = ObservableStore(state: 0, update: updateCounter)var body: some View {
VStack {
Text("\(store.state)")
Button(action: { self.store.dispatch(.increment) }) {
Text("Increment")
}
}
}
}```
## Contributing
All contributions are welcome.
Project was created by [Matěj Kašpar Jirásek](https://github.com/mkj-is).
Project is licensed under [MIT license](LICENSE.txt).