{"id":17802911,"url":"https://github.com/makesource/viewmodelbindable","last_synced_at":"2025-03-17T11:31:12.015Z","repository":{"id":56926019,"uuid":"129711663","full_name":"makesource/ViewModelBindable","owner":"makesource","description":"⚡️Super easy way to bind ViewModel","archived":false,"fork":false,"pushed_at":"2018-05-08T13:42:54.000Z","size":611,"stargazers_count":23,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-27T23:30:06.517Z","etag":null,"topics":["dependency-injection","mvvm-architecture","reactive","swift"],"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/makesource.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-04-16T08:39:56.000Z","updated_at":"2022-05-11T09:23:37.000Z","dependencies_parsed_at":"2022-08-21T04:20:48.005Z","dependency_job_id":null,"html_url":"https://github.com/makesource/ViewModelBindable","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/makesource%2FViewModelBindable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/makesource%2FViewModelBindable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/makesource%2FViewModelBindable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/makesource%2FViewModelBindable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/makesource","download_url":"https://codeload.github.com/makesource/ViewModelBindable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243858796,"owners_count":20359424,"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":["dependency-injection","mvvm-architecture","reactive","swift"],"created_at":"2024-10-27T12:44:53.395Z","updated_at":"2025-03-17T11:31:11.498Z","avatar_url":"https://github.com/makesource.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ViewModelBindable\n⚡️Super easy way to bind ViewModel\n\n1. typealias your ViewModel which you want to inject\n```swift\ntypealias ViewModel = DetailViewModel\n```\n\n2. Inject viewModel\n```swift\nlet viewController = DetailViewController()\nlet viewModel = DetailViewModel()\nviewController.viewModel = viewModel\n```\n\n3. Just enjoy `bindViewModel(_:)`, `bindStyles()` \u003cbr/\u003e This will be called automatically!\n\n## Usages\nJust confrom your UIView or UIViewController to ViewModelBindable!\n\nViewModelBindable offers two binding method bindViewModel(_:), bindStyles()\n\n\n- **UIViewController**\n```swift\nclass DetailViewController: UIViewController {\n  var disposeBag = DisposeBag()\n  ...\n}\n\nextension DetailViewController: ViewModelBindable {\n  typealias ViewModel = DetailViewModel\n  \n  // perform binding here\n  func bindViewModel(viewModel: ViewModel) {\n  }\n  \n  // This method is optional\n  // Implement if you need\n  func bindStyles() {\n  }\n}\n```\n- **UIView**\n```swift\nclass DetailView: UIView {\n  var disposeBag = DisposeBag()\n  ...\n}\n\nextension DetailView: ViewModelBindable {\n  typealias ViewModel = DetailViewModel\n  \n  // perform binding here\n  func bindViewModel(viewModel: ViewModel) {\n  }\n  \n  // This method is optional\n  // Implement if you need\n  func bindStyles() {\n  }\n}\n```\n\n## Features\n\nViewModelBindable serves two binding methods which was used in MVVM architecture.\n\n### `bindViewModel()`\n\n#### Usage\n\n`bindViewModel()` is used for binding between View and ViewModel.\n\n#### When is it called?\n\nRight **after** UIViewController's `viewDidLoad()`\n\nRight **after** UIView's viewModel injection\n\nIt's recommended to bind UIView's viewModel in ViewController's bindViewModel(_:) method \n\n```swift\nfunc bindViewModel(viewModel: ViewModel) {\n  headerView.viewModel = viewModel\n  footerView.viewModel = viewModel\n}\n```\n \nYou can initialize some stuffs in viewDidLoad / awakeFromNib to prepare binding if you use storyboard\n\n\n### `bindStyles()`\n\n#### Usage\n\n`bindStyles()` is used for styling your views. This method is optional. So implement it if you need.\n\n- If your app support localized text or images, then styling it in 'bindStyles()'\n- If your app support theme-based design that depends on user setting\n- If your app does not use Storyboard\n\n#### When is it called?\n\nRight **before** UIViewController's initial `viewWillAppear(_:)` call and each time `traitCollectionDidChange(_:)` call\n \nRight **before** each time UIView's `traitCollectionDidChange(_:)` call\n\n## Dependency\n\n- [RxSwift](https://github.com/ReactiveX/RxSwift) (\u003e= 4.0.0)\n\n## Requirements\n\n- iOS 8.0+\n- Xcode 7.3+\n\n## Installation\n\nViewModelBindable is available through [CocoaPods](http://cocoapods.org). To install\nit, simply add the following line to your Podfile:\n\n```ruby\npod 'ViewModelBindable'\n```\n\n## Author\n\n[makesource](https://github.com/makesource), makesource@gmail.com\n\n## License\n\nViewModelBindable 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%2Fmakesource%2Fviewmodelbindable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmakesource%2Fviewmodelbindable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmakesource%2Fviewmodelbindable/lists"}