0

我无法弄清楚将这两个可观察对象、属性ConfigurationBalanceDtosRx.NET 结合起来的语法是什么,可以在 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.NET 的其他示例CombineLatest,但它们总是组合相同类型的对象。

4

1 回答 1

0

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

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];
            });
        }
    }
于 2020-12-12T20:43:00.390 回答