Swiftpack.co - heroesofcode/DataLife as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by heroesofcode.
heroesofcode/DataLife v1.0.5
DataLife is an observable data storage class written in Swift for iOS, tvOS & macOS.
⭐️ 3
🕓 1 year ago
iOS macOS tvOS
.package(url: "https://github.com/heroesofcode/DataLife.git", from: "v1.0.5")

CI codecov Swift Version Tag Cocoapods compatible Carthage compatible SPM compatible GitHub

Overview

DataLife is an observable data storage class

Support

How to use?

  • In ViewModel inherit from DataLifeViewModel and create a variable that will be the result value.
import DataLife

class ViewModel: DataLifeViewModel {
    
    var myName = DataLife<String>()
    
    func fetchMyName() {
        myName.value = "Darth Vader"
    }
    
}
  • In the ViewController you will call the variable that was created in the ViewModel that will be observed.
import UIKit

class ViewController: UIViewController {
    
    private let viewModel = ViewModel()

    override func viewDidLoad() {
        super.viewDidLoad()
        
        setupState()
        setupFetchMyName()
    }

    private func setupFetchMyName() {
        viewModel.fetchMyName()
    }
    
    private func setupState() {
        viewModel.myName.observer(viewModel) { name in
            print(name)
        }
    }
}

Installation

Swift Package Manager
import DataLife
dependencies: [
    .package(url: "https://github.com/joaolfp/DataLife.git", .upToNextMajor(from: "1.2.5"))
]
CocoaPods
import DataLife
target '<Your Target Name>' do
  pod 'DataLife'
end
$ pod install
Carthage
github "heroesofcode/DataLife"

Author

Coded by João Lucas

License

MIT License

Copyright (c) 2020 João Lucas

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
© 2020 GitHub, Inc.

GitHub

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

Release Notes

45 weeks ago

Feature

  • Add support to tvOS

Fix and improvements

  • Adjustment and correction of public methods

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics