将来自不同可观测值的多个排放分组为一个排放

Group multiple emissions from different observables into one emission

我有以下 3 个可观察值:

Observable<List<Action>> actions

Observable<List<Type>> types

Observable<List<Unit>> units

我想观察所有 observable 的所有发射并将它们放入哈希映射中:

从第一个观察

hashMap.put("Actions", actions);

来自第二个可观察对象

hashMap.put("Types", types);

来自第三个观察

hashMap.put("Units", units);

然后我想在所有可观察对象完成后发出 hashMap

注:

Zip — combine the emissions of multiple Observables together via a specified function and emit single items for each combination based on the results of this function

您正在寻找 zip 运算符。压缩操作、类型和单位 Observables 并在组合函数中创建你的哈希映射。结果将是一个 Hash Map 的 Observable。