Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vmanot/reactor
The most advanced state management framework for SwiftUI.
https://github.com/vmanot/reactor
Last synced: 5 days ago
JSON representation
The most advanced state management framework for SwiftUI.
- Host: GitHub
- URL: https://github.com/vmanot/reactor
- Owner: vmanot
- Created: 2019-12-12T16:11:41.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-09-15T11:41:30.000Z (about 2 months ago)
- Last Synced: 2024-11-01T02:34:46.310Z (12 days ago)
- Language: Swift
- Homepage:
- Size: 270 KB
- Stars: 19
- Watchers: 6
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Reactor
A state management framework for SwiftUI.## Why
Reactor is a Flux-inspired, reactive state management
```swift
struct ExampleView: ReactorView {
let reactor: Reactor
init(reactor: Reactor) {
self.reactor = reactor
}
func makeBody(reactor: Reactor) -> some View {
Group {
if reactor.status(of: .foo) == .active {
ActivityIndicator()
} else {
reactor.taskButton(for: .foo) {
Text("Run foo!")
}
}
}
}
}extension ExampleView {
struct Reactor: ViewReactor {
enum Action: Hashable {
case foo
}
@ViewReactorEnvironment() var environment
}
}extension ExampleView.Reactor {
func task(for action: Action) -> ActionTask {
switch action {
case .foo:
return Just(())
.delay(for: .seconds(1), scheduler: DispatchQueue.main)
.eraseToActionTask()
}
}
}
```