StoreSwift is a streamlined library designed to facilitate undirectional data flow architecture.
No single architecture is perfectly suited for every application. Many architectures in iOS come with scalability challenges:
First you need to define a UseCase:
struct ProfileUseCase: UseCase {
struct Props: Equatable {
var isLoading = false
}
enum Action {
case viewAppeared
}
enum Effect {
case setLoading(Bool)
}
var reducer: Reducer {
return { state, effect in
switch effect {
case let .setLoading(value):
state.isLoading = value
}
}
}
var middleware: Middleware {
return { state, action in
switch action {
case let .viewAppeared(value):
return .merge(
.effect(.setLoading(true),
.run { // perform asyncronous task and return Effect }
)
}
}
}
}
Then simple use it in view:
@PropsObject var store: Store<ProfileUseCase>
...
store.isLoading
...
store.send(.viewAppeared)
...
store.$state.sink { state in ... }
Simple to use.
StoreSwift supports iOS 13 and up, and can be compiled with Swift 5.5 and up.
The StoreSwift package URL is:
`https://github.com/alobanov11/StoreSwift`
StoreSwift is licensed under the Apache-2.0 Open Source license.
You are free to do with it as you please. We do welcome attribution, and would love to hear from you if you are using it in a project!
link |
Stars: 0 |
Last commit: 6 days ago |
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics