Swiftpack.co - heroesofcode/DataLife as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
heroesofcode/DataLife
DataLife is an observable data storage class for Swift
.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.1.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: Yesterday

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Submit a free job ad (while I'm testing this). The analytics numbers for this website are here.

Release Notes

MacOS Support
1 week ago

Feature

  • Add support to MacOS

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