KVO-MVVM 0.5.6

KVO-MVVM 0.5.6

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Feb 2019

Maintained by Anton Bukov, Andrew Podkovyrin, vdugnist, Arkady Fraerman.



KVO-MVVM 0.5.6

  • By
  • Anton Bukov and Andrew Podkovyrin

KVO-MVVM

CI Status Version License Platform

Usage

  1. First #import <KVO-MVVM/KVOUIView.h> or any other available header
  2. Subclass your custom view from KVOUIView
  3. Use mvvm_observe:with: or mvvm_observeCollection:with: like this:
   - (instancetype)initWithFrame:(CGRect)frame {
       if (self = [super initWithFrame:frame]) {

           [self mvvm_observe:@keypath(self.viewModel.title)
                         with:^(typeof(self) self, NSString *title) {
               self.titleLabel.text = self.viewModel.title;
           }];
           
           [self mvvm_observeCollection:@keypath(self.viewModel.values)
                                   with:^(typeof(self) self,
                                          NSArray<NSNumber *> *value,
                                          NSKeyValueChange change,
                                          NSIndexSet *indexes) {
               // ...
           }];

       }
       return self;
   }
  1. Do not unobserve any KVO-observings any more

Observing keypaths with weak properties in it is not supported.

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

KVO-MVVM is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'KVO-MVVM'

Authors

Anton Bukov, [email protected] Andrew Podkovyrin, [email protected]

License

KVO-MVVM is available under the MIT license. See the LICENSE file for more info.