{"id":19313640,"url":"https://github.com/geektree0101/vetty","last_synced_at":"2026-04-18T03:32:10.861Z","repository":{"id":56926026,"uuid":"159909567","full_name":"GeekTree0101/Vetty","owner":"GeekTree0101","description":"Very easy commit \u0026 read \u0026 mutation mechanism about all of model, Reactive Model Provider built on RxSwift","archived":false,"fork":false,"pushed_at":"2018-12-15T03:02:43.000Z","size":288,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-07T05:03:11.243Z","etag":null,"topics":["ios","model","provider-engine","reactive-programming","rxswift","rxswift-extensions"],"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/GeekTree0101.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-12-01T04:40:25.000Z","updated_at":"2018-12-15T03:01:54.000Z","dependencies_parsed_at":"2022-08-21T04:20:48.620Z","dependency_job_id":null,"html_url":"https://github.com/GeekTree0101/Vetty","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GeekTree0101%2FVetty","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GeekTree0101%2FVetty/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GeekTree0101%2FVetty/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GeekTree0101%2FVetty/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GeekTree0101","download_url":"https://codeload.github.com/GeekTree0101/Vetty/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240415272,"owners_count":19797603,"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":["ios","model","provider-engine","reactive-programming","rxswift","rxswift-extensions"],"created_at":"2024-11-10T00:40:32.264Z","updated_at":"2026-04-18T03:32:10.823Z","avatar_url":"https://github.com/GeekTree0101.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"![alt text](https://github.com/GeekTree0101/Vetty/blob/master/res/logo.png)\n\n[![CI Status](https://img.shields.io/travis/Geektree0101/Vetty.svg?style=flat)](https://travis-ci.org/Geektree0101/Vetty)\n[![Version](https://img.shields.io/cocoapods/v/Vetty.svg?style=flat)](https://cocoapods.org/pods/Vetty)\n[![License](https://img.shields.io/cocoapods/l/Vetty.svg?style=flat)](https://cocoapods.org/pods/Vetty)\n[![Platform](https://img.shields.io/cocoapods/p/Vetty.svg?style=flat)](https://cocoapods.org/pods/Vetty)\n\n## Feature\nLink: https://github.com/GeekTree0101/Vetty/projects/2\n\n\u003cbr /\u003e\u003cbr /\u003e\u003cbr /\u003e\n\n## Usage\n\u003cbr /\u003e\n\n### Make a model\n\u003cbr /\u003e\n\n```swift\nclass User: VettyProtocol { // \u003c--- STEP1: Inherit VettyProtocol\n    \n    var uniqueKey: VettyIdentifier {\n        return userId // \u003c--- STEP2: return model uniqueKey\n    }\n    \n    var userId: Int = -1\n    var username: String = \"\"\n    var profileURL: URL?\n    \n    enum CodingKeys: String, CodingKey {\n        case userId = \"id\"\n        case username = \"login\"\n        case profileURL = \"avatar_url\"\n    }\n    \n    func commitSubModelIfNeeds() { // \u003c---- STEP3: (Optional) \n        // Will pass, user model doen't has VettyProtocol Sub-Model\n    }\n}\n```\n\u003cbr /\u003e\u003cbr /\u003e\n\n### Commit\n\u003cbr /\u003e\n\n1. Directly commit model\n```swift\nlet userIdForVetty: VettyIdentifier = Vetty.shared.commit(user)\n```\n\n2. Using Reactive Extension\n```swift\nlet userIdForVettyObservable: Observable\u003cVettyIdentifier\u003e =\n  Observable.just(user)\n            .asObservable()\n            .map({ $0.map({ $0 as VettyProtocol }) })\n            .commits(ignoreSubModel: false)\n```\n\u003cbr /\u003e\u003cbr /\u003e\n\n\n### READ\n\u003cbr /\u003e\n\n\u003e Directly read model object from Vetty\n```swift\nlet user: User? = Vetty.shared.read(type: User.self, uniqueKey: 12345)\n\n```\n\u003cbr /\u003e\u003cbr /\u003e\n\n### Model Observable\n\u003cbr /\u003e\n\n```swift\nlet userObservable: Observable\u003cUser?\u003e = Vetty.rx.observer(type: User.self, uniqueKey: 12345)\n```\n\u003cbr /\u003e\u003cbr /\u003e\n\n### Mutating\n\u003cbr /\u003e\n\n1. Directly Mutating\n```swift\nguard let user = Vetty.shared.read(type: User.self, uniqueKey: 12345) else { return }\nuser.profileURL = URL(string: \"https://avatars1.githubusercontent.com/u/19504988?s=460\u0026v=4\")\nVetty.shared.commit(user, ignoreSubModel: true)\n```\n\u003cbr /\u003e\u003cbr /\u003e\n\n2. Using Observable Extension\n```swift\nlet observable: Observable\u003cUser?\u003e = Vetty.rx.observer(type: User.self, uniqueKey: 12345)\nObservable.just(URL(string: \"https://avatars1.githubusercontent.com/u/19504988?s=460\u0026v=4\"))\n          .mutate(with: observable,\n                  { user, newURL -\u003e User? in\n                      user?.profileURL = newURL\n                      return user\n            })\n            .disposed(by: disposeBag)\n```\n\u003cbr /\u003e\u003cbr /\u003e\n\n## Advanced\n\u003cbr /\u003e\u003cbr /\u003e\n\n\n### Sub-Model Observable from Root-Model Observable\n\u003cbr /\u003e\n\n```swift\nlet repoObservable = Vetty.rx.observer(type: Repository.self, uniqueKey: repoId)\n        \nlet userObservable = repoObservable\n            .filterNil()\n            .map { $0.user?.uniqueKey }\n            .asObserver(type: User.self)\n```\n\u003cbr /\u003e\u003cbr /\u003e\n\n### Ignore Sub-Model Mutating\n\u003cbr /\u003e\n\n```swift\nlet observable: Observable\u003cUser?\u003e = Vetty.rx.observer(type: User.self, uniqueKey: 12345)\nObservable.just(URL(string: \"https://avatars1.githubusercontent.com/u/19504988?s=460\u0026v=4\"))\n          .mutate(with: observable,\n                  ignoreSubModel: true) \u003c--- Default is true!\n                  { user, newURL -\u003e User? in\n                      user?.profileURL = newURL\n                      return user\n            })\n            .disposed(by: disposeBag)\n```\n\u003cbr /\u003e\u003cbr /\u003e\n\n### Non-Ignore Sub-Model with Latest Sub-Model\n\u003cbr /\u003e\n\n\u003e Model Example, Repository has User(Sub-Model) property!\n```swift\n\nclass Repository: VettyProtocol {\n    \n    var uniqueKey: VettyIdentifier {\n        return id\n    }\n    \n    var id: Int = -1\n    var user: User?\n    var repositoryName: String?\n    var desc: String?\n    var isPrivate: Bool = false\n    var isForked: Bool = false\n    \n    enum CodingKeys: String, CodingKey {\n        case id = \"id\"\n        case user = \"owner\"\n        case repositoryName = \"full_name\"\n        case desc = \"description\"\n        case isPrivate = \"private\"\n        case isForked = \"fork\"\n    }\n    \n    func commitSubModelIfNeeds() {\n        \n        Vetty.shared.commitIfNeeds(user)\n    }\n}\n\nclass User: VettyProtocol {\n    \n    var uniqueKey: VettyIdentifier {\n        return userId\n    }\n    \n    var userId: Int = -1\n    var username: String = \"\"\n    var profileURL: URL?\n    \n    enum CodingKeys: String, CodingKey {\n        case userId = \"id\"\n        case username = \"login\"\n        case profileURL = \"avatar_url\"\n    }\n    \n    func commitSubModelIfNeeds() {\n        \n    }\n}\n\n```\n\n\u003cbr /\u003e\n\nIf you don't wanna update user model(sub-model) than you just should set ignoreSubModel as True.\nBut, If uou should update repository model(root-model) with latest user model from vetty \nthan you just follow under the example.\n\n\u003cbr /\u003e\n\n\n```swift\nlet observable: Observable\u003cRepository?\u003e = Vetty.rx.observer(type: Repository.self, uniqueKey: \"repo-23\")\nObservable.just(\"New Repository Description\")\n          .mutate(with: observable,\n                  ignoreSubModel: false) \n                  { repo, newDesc -\u003e Repository? in\n                      \n                      if let userId = repo.user?.userId, \n                      let latestUser = Vetty.shared.read(type: User.self, uniqueKey: userId) {\n                        repo.user = latestUser\n                      }\n                      \n                      repo?.desc = newDesc\n                      return repo\n            })\n            .disposed(by: disposeBag)\n```\n\n\u003cbr /\u003e\u003cbr /\u003e\n\n## Installation\n\nVetty is available through [CocoaPods](https://cocoapods.org). To install\nit, simply add the following line to your Podfile:\n\n```ruby\npod 'Vetty'\n```\n\n## Author\n\nGeektree0101, h2s1880@gmail.com\n\n## License\n\nVetty is available under the MIT license. See the LICENSE file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeektree0101%2Fvetty","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeektree0101%2Fvetty","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeektree0101%2Fvetty/lists"}