Miniature can be used to handle loading data from both local and remote sources, as well as caching the data locally.
Swift Package Manager is a tool for managing the distribution of Swift code. It’s integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies.
To integrate Miniature
into your Xcode project using Swift Package Manager, add it to the dependencies value of your Package.swift:
dependencies: [
.package(url: "https://github.com/GSM-MSG/Miniature.git", .upToNextMajor(from: "1.1.1"))
]
If you prefer not to use either of the aforementioned dependency managers, you can integrate Miniature into your project manually.
struct Test {
var int = 0
func localData() -> Int {
return int
}
func remoteData() -> AnyPublisher<Int, Error> {
Just(2).delay(for: 2, scheduler: RunLoop.main)
.setFailureType(to: Error.self)
.eraseToAnyPublisher()
}
mutating func updateLocal(int: Int) {
self.int = int
}
}
final class ViewController: UIViewController {
var bag = Set<AnyCancellable>()
override func viewDidLoad() {
super.viewDidLoad()
var test = Test()
Miniature {
test.localData()
} onRemote: {
test.remoteData()
} refreshLocal: { value in
test.updateLocal(int: value)
}
.publish { status in
status.action { load in
print("LOAD", load)
} onCompleted: { complete in
print("COMPLETE", complete)
} onError: { err in
print(err)
}
}
.store(in: &bag)
}
}
link |
Stars: 2 |
Last commit: 3 weeks ago |
Full Changelog: https://github.com/GSM-MSG/Miniature/compare/1.1.1...1.2.0
'RxMiniature' 패키지를 추가하여 Miniature가 RxSwift도 지원할 수 있게 합니다
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics