ios - MVVM with ReactiveCocoa, how does ViewModel tell View to do some one time operation? -


for example, want view show toast, way i'm doing like:

in view:

racobserve(self.viewmodel, showtoast) subscribenext:^(nsnumber *isshow) {     if (isshow.boolvalue) {         self showtoast];     } } 

showtoast property of viewmodel, don't think way descriptive, there more standard, more elegant way achieve this?

to give more descriptive, create racsubject manually send notifications using [self.toastssubject sendnext:@"toast info string of kind"].

@weakify(self) [self.viewmodel.toastssubject subscribenext:^(id _) {     @strongify(self)     [self showtoast]; } 

even better, have showtoast take single argument (such content of toast), don't need use @weakify , @strongify, instead lift signal directly using rac_liftselector.

[self rac_liftselector:@selector(showtoast:)       withsignals:self.viewmodel.toastssubject, nil]; 

Comments

Popular posts from this blog

java - Andrioid studio start fail: Fatal error initializing 'null' -

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -