Swiftpack.co - GSM-MSG/Miniature as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by GSM-MSG.
GSM-MSG/Miniature 1.2.0
Repository pattern support library
⭐️ 2
🕓 7 weeks ago
iOS macOS watchOS tvOS
.package(url: "https://github.com/GSM-MSG/Miniature.git", from: "1.2.0")

Miniature

Miniature can be used to handle loading data from both local and remote sources, as well as caching the data locally.

Document


Contents


Requirements

  • iOS 13.0+ / tvOS 13.0+ / watchOS 6.0+ / macOS 10.15+
  • Swift 5+

Communication

  • If you found a bug, open an issue.
  • If you have a feature request, open an issue.
  • If you want to contribute, submit a pull request.

Installation

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"))
]

Manually

If you prefer not to use either of the aforementioned dependency managers, you can integrate Miniature into your project manually.


Usage

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)
    }
}

GitHub

link
Stars: 2
Last commit: 3 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Dependencies

Release Notes

1.2.0 RxMiniature
7 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