Reactive UI how to use WhenAny using two properties?

落花浮王杯 提交于 2019-12-11 09:59:50

问题


I am trying to use WhenAny (Reactive UI) for the first time.

When a Identifier =="xyz" and a IsMax field get changes, want to set a local value to true in the subscribe,

   this.WhenAny(x => x.IsMax, x => x.Value)
       .Subscribe(x => 
            {
                if (Identifier == "xyz")
                {  
                   isOk = true; 
                }
            });

but is there any other way to merge Identifier condition as well?


回答1:


I'm not familiar with ReactiveUI, but if it uses the same IObservable as Reactive Extensions, then you could do this:

   this.WhenAny(x => x.IsMax, x => x.Value)
       .Where(_ => Identifier == "xyz")
       .Subscribe(_ => 
           {
               isOk = true;
           });

Is this what you wanted?

PS.: I should have asked this in a comment, but I haven't got enough reputation yet.



来源:https://stackoverflow.com/questions/28804765/reactive-ui-how-to-use-whenany-using-two-properties

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!