{"id":13902836,"url":"https://github.com/ReactiveCocoa/ReactiveViewModel","last_synced_at":"2025-07-18T00:32:12.837Z","repository":{"id":8970113,"uuid":"10712489","full_name":"ReactiveCocoa/ReactiveViewModel","owner":"ReactiveCocoa","description":"Model-View-ViewModel, using ReactiveCocoa","archived":true,"fork":false,"pushed_at":"2018-06-02T12:32:48.000Z","size":102,"stargazers_count":1956,"open_issues_count":15,"forks_count":259,"subscribers_count":73,"default_branch":"master","last_synced_at":"2024-10-24T04:33:53.968Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Objective-C","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/ReactiveCocoa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-06-15T21:49:33.000Z","updated_at":"2024-05-19T19:25:37.000Z","dependencies_parsed_at":"2022-09-03T02:53:23.529Z","dependency_job_id":null,"html_url":"https://github.com/ReactiveCocoa/ReactiveViewModel","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ReactiveCocoa%2FReactiveViewModel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ReactiveCocoa%2FReactiveViewModel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ReactiveCocoa%2FReactiveViewModel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ReactiveCocoa%2FReactiveViewModel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ReactiveCocoa","download_url":"https://codeload.github.com/ReactiveCocoa/ReactiveViewModel/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225637121,"owners_count":17500361,"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":[],"created_at":"2024-08-06T22:01:27.202Z","updated_at":"2024-11-25T11:30:34.084Z","avatar_url":"https://github.com/ReactiveCocoa.png","language":"Objective-C","readme":"\n# ReactiveViewModel [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n\nReactiveViewModel is a combination code/documentation project for building Cocoa\napplications using [Model-View-ViewModel](#model-view-viewmodel) and\n[ReactiveCocoa](#reactivecocoa).\n\nBy explaining rationale, documenting best practices, and providing reusable\nlibrary components, we want to make MVVM in Objective-C appealing and easy.\n\n## Model-View-ViewModel\n\nMost Cocoa developers are familiar with the\n[Model-View-Controller](http://en.wikipedia.org/wiki/Model-View-Controller)\n(MVC) pattern:\n\n![Model-View-Controller](https://f.cloud.github.com/assets/432536/867983/280867ea-f760-11e2-9425-8d1345ffdfb9.png)\n\n**[Model-View-ViewModel](http://en.wikipedia.org/wiki/Model-View-ViewModel)\n(MVVM)** is another architectural paradigm for GUI applications:\n\n![Model-View-ViewModel](https://f.cloud.github.com/assets/432536/867984/291ed380-f760-11e2-9106-d3158320af39.png)\n\nAlthough it seems similar to MVC (except with a \"view model\" object in place of\nthe controller), there's one major difference — **the view owns the view\nmodel**. Unlike a controller, a view model has no knowledge of the specific view\nthat's using it.\n\nThis seemingly minor change offers huge benefits:\n\n 1. **View models are testable.** Since they don't need a view to do their work,\n    presentation behavior can be tested without any UI automation or stubbing.\n 1. **View models can be used like models.** If desired, view models can be\n    copied or serialized just like a domain model. This can be used to quickly\n    implement UI restoration and similar behaviors.\n 1. **View models are (mostly) platform-agnostic.** Since the actual UI code\n    lives in the view, well-designed view models can be used on the iPhone,\n    iPad, and Mac, with only minor tweaking for each platform.\n 1. **Views and view controllers are simpler.** Once the important logic is\n    moved elsewhere, views and VCs become dumb UI objects. This makes them\n    easier to understand and redesign.\n\nIn short, replacing MVC with MVVM can lead to more versatile and rigorous UI\ncode.\n\n### What's in a view model?\n\nA view model is like an [adapter](http://en.wikipedia.org/wiki/Adapter_pattern)\nfor the model that makes it suitable for presentation. The view model is also\nwhere presentation _behavior_ goes.\n\nFor example, a view model might handle:\n\n * Kicking off network or database requests\n * Determining when information should be hidden or shown\n * Date and number formatting\n * Localization\n\nHowever, the view model is not responsible for actually presenting\ninformation or handling input — that's the sole domain of the view layer. When\nthe view model needs to communicate something to the view, it does so through\na system of [data binding](#reactivecocoa).\n\n### What about view controllers?\n\nOS X and iOS both have view (or window) controllers, which may be confusing at\nfirst glance, since MVVM only refers to a view.\n\nBut upon closer inspection, it becomes apparent that view controllers are\n_actually just part of the view layer_, since they handle things like:\n\n * Layout\n * Animations\n * Device rotation\n * View and window transitions\n * Presenting loaded UI\n\nSo, \"the view\" actually means the view _layer_, which includes view controllers.\nThere's no need to have a view and a view controller for the same section of the\nscreen, though — just pick whichever class is easier for the use case.\n\nNo matter whether you decide to use a view or a view controller, you'll still\nhave a view model.\n\n## ReactiveCocoa\n\nMVVM is most successful with a powerful system of [data\nbinding](http://en.wikipedia.org/wiki/UI_data_binding).\n[ReactiveCocoa](https://github.com/ReactiveCocoa/ReactiveCocoa) is one such\nsystem.\n\nBy modeling changes as\n[signals](https://github.com/ReactiveCocoa/ReactiveCocoa#introduction), the view\nmodel can communicate to the view without actually needing to know that it\nexists (similarly for model → view model communication). This decoupling is\nwhy view models can be tested without a view in place — the test simply needs to\nconnect to the VM's signals and verify that the behavior is correct.\n\nReactiveCocoa also includes other conveniences that are hugely beneficial for\nMVVM, like\n[commands](https://github.com/ReactiveCocoa/ReactiveCocoa/blob/master/Documentation/FrameworkOverview.md#commands),\nand built-in bindings for AppKit and UIKit.\n\n## Getting Started\n\nTo build ReactiveViewModel in isolation, open `ReactiveViewModel.xcworkspace`. To integrate it into your project, include `ReactiveViewModel.xcodeproj` and `ReactiveCocoa.xcodeproj` and link your target against the ReactiveViewModel and ReactiveCocoa targets for your platform.\n\n## More Resources\n\nModel-View-ViewModel was originally developed by\n[Microsoft](http://bit.ly/gQY00r), so many of the examples are specific to WPF\nor Silverlight, but there are still a few resources that may be useful:\n\n**Blog posts:**\n\n * [Basic MVVM with ReactiveCocoa](http://cocoasamurai.blogspot.com/2013/03/basic-mvvm-with-reactivecocoa.html)\n * [Model-View-ViewModel for iOS](http://www.teehanlax.com/blog/model-view-viewmodel-for-ios/)\n * [Presentation Model](http://martinfowler.com/eaaDev/PresentationModel.html)\n\n**Presentations:**\n\n * [Code Reuse with MVVM](https://speakerdeck.com/jspahrsummers/code-reuse-with-mvvm)\n","funding_links":[],"categories":["Objective-C","**Index**"],"sub_categories":["ReactiveCocoa should transform EVERYTHING when it comes to writing iOS code so here's a bunch of projects that should make your RAC transtion a little bit smoother"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FReactiveCocoa%2FReactiveViewModel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FReactiveCocoa%2FReactiveViewModel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FReactiveCocoa%2FReactiveViewModel/lists"}