如何将Rx.NET中的CombineLatest用于两种不同类型



我不知道把Rx.NET中的属性ConfigurationBalanceDtos这两个可观测值组合在一起的语法是什么,可以在RxJS中完成吗?没问题(下面的例子(,有什么想法吗?这是我所能得到的最接近的,但它不正确。

public IObservable<Subroutine> Configuration { get; set; }
public List<IObservable<List<OtherObject>>> BalanceDtos { get; set; }
public IObservable<List<OtherObject>> GetSubRoutinesTotal
{
get
{
return Observable.CombineLatest(Configuration, BalanceDtos.CombineLatest()).Select((config, bals) =>
{
Subroutine test1 = config; //these are the objects that I want coming out of this CombineLatest observable.
List<OtherObject> test2 = bals;
});
}
}

因此,我想要的是,当属性Configuration observable更改,或者BalanceDto属性中的任何observable发生更改时,它应该发出该更改

大理石:

-c1-b1-b2-b3-c2
---[c1,b1]-[c1,b2]-[c1-b3]-[c2,b3] 

使用打字脚本中的RxJS,我会写以下内容:

let obsArray$: Observable<Subroutine>;
let otherModel$: Observable<OtherObject>[];
combineLatest([obsArray$, combineLatest(otherModel$)]).subscribe(([obsArray, otherModel]) => {
let test1: Subroutine = obsArray;
let tes2: OtherObject[] = otherModel;
});

我只是不知道Rx.NET中相同事物的语法是什么。我看过Rx.NETCombineLatest的其他示例,但它们总是组合相同类型的对象。

我现在已经想好了如何做到这一点,下面是解决方案:

public IObservable<Subroutine> Configuration { get; set; }
public List<IObservable<List<OtherObject>>> BalanceDtos { get; set; }
public IObservable<List<OtherObject>> GetSubRoutinesTotal
{
get
{
return BalanceDtos.CombineLatest().CombineLatest(Configuration, (bals, config) =>
{
Subroutine test1 = config; //these are the objects that I want coming out of this CombineLatest observable.
IList<List<OtherObject>> test2 = bals;
return test2[0];
});
}
}

最新更新