{"id":18308505,"url":"https://github.com/heroesofcode/datalife","last_synced_at":"2025-04-05T17:32:13.238Z","repository":{"id":41959410,"uuid":"291378339","full_name":"heroesofcode/DataLife","owner":"heroesofcode","description":"DataLife is an observable data storage class written in Swift","archived":false,"fork":false,"pushed_at":"2024-05-21T02:57:48.000Z","size":283,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-05-21T03:53:15.181Z","etag":null,"topics":["datalife","ios","macos","swift-package-manager","tvos"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/heroesofcode.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-08-30T01:33:14.000Z","updated_at":"2024-06-25T06:00:51.347Z","dependencies_parsed_at":"2023-09-23T07:57:37.940Z","dependency_job_id":"e1259809-d913-4e51-8a48-00820c3e0fda","html_url":"https://github.com/heroesofcode/DataLife","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heroesofcode%2FDataLife","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heroesofcode%2FDataLife/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heroesofcode%2FDataLife/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heroesofcode%2FDataLife/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/heroesofcode","download_url":"https://codeload.github.com/heroesofcode/DataLife/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247375027,"owners_count":20928936,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["datalife","ios","macos","swift-package-manager","tvos"],"created_at":"2024-11-05T16:08:15.346Z","updated_at":"2025-04-05T17:32:11.281Z","avatar_url":"https://github.com/heroesofcode.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://raw.githubusercontent.com/heroesofcode/DataLife/master/assets/logo.png\"\u003e\n\u003c/p\u003e\n\n[![CI](https://github.com/heroesofcode/DataLife/actions/workflows/CI.yml/badge.svg)](https://github.com/heroesofcode/DataLife/actions/workflows/CI.yml)\n[![SPM compatible](https://img.shields.io/badge/SPM-compatible-brightgreen)](https://swift.org/package-manager/)\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fheroesofcode%2FDataLife%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/heroesofcode/DataLife)\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fheroesofcode%2FDataLife%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/heroesofcode/DataLife)\n[![GitHub](https://img.shields.io/github/license/heroesofcode/DataLife)](https://github.com/joaolfp/DataLife/blob/master/LICENSE)\n\n## Overview\n\nDataLife is an observable data storage class\n\n## Usage\n\n- In ViewModel inherit from DataLifeViewModel and create a variable that will be the result value.\n\n```swift\nimport DataLife\n\nfinal class ViewModel: DataLifeViewModel {\n    \n    var myName = DataLife\u003cString\u003e()\n    \n    func fetchMyName() {\n        myName.value = \"Darth Vader\"\n    }\n    \n}\n```\n- In the ViewController you will call the variable that was created in the ViewModel that will be observed.\n\n``` swift\nimport UIKit\n\nfinal class ViewController: UIViewController {\n    \n    @IBOutlet weak var nameLabel: UILabel!\n    \n    private let viewModel = ViewModel()\n    \n    override func viewDidLoad() {\n        super.viewDidLoad()\n        \n        setupState()\n        setupFetchMyName()\n    }\n\n    private func setupFetchMyName() {\n        viewModel.fetchMyName()\n    }\n    \n    private func setupState() {\n        viewModel.myName.addObserver(viewModel) { [weak self] name in\n            self?.nameLabel.text = name\n        }\n    }\n}\n```\n\n## Demo\nYou see the demo [here](https://github.com/heroesofcode/DataLife/tree/master/Example)\n\n## Installation\n\n### [Swift Package Manager (SPM)](https://swift.org/package-manager)\n\n```swift\nimport PackageDescription\nlet package = Package(\n    name: \"\u003cYour Product Name\u003e\",\n    dependencies: [\n       .package(url: \"https://github.com/heroesofcode/DataLife\", .upToNextMajor(from: \"2.0.0\"))\n    ],\n    targets: [\n        .target(\n            name: \"\u003cYour Target Name\u003e\",\n            dependencies: [\"DataLife\"]),\n    ]\n)\n```\n\n## Contributing\n\nTo contribute, just fork this project and then open a pull request, feel free to contribute, bring ideas and raise any problem in the issue tab.\n\n    \n## License\n\nDataLife is released under the MIT license. See [LICENSE](https://github.com/heroesofcode/DataLife/blob/master/LICENSE) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheroesofcode%2Fdatalife","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fheroesofcode%2Fdatalife","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheroesofcode%2Fdatalife/lists"}