[英]Object assign with rxjs5
Hy, what is functional way to create object and use values from rxjs5 observables? 嗨,从rxjs5可观察对象创建对象并使用值的函数方法是什么?
let _id = myObservableOne.pluck('id')
let _name = myObservableSecond.pluck('name')
let _path = myObservableThird.pluck('path')
let newObj = {
id: _id,
name: _name,
path: _path
}
Depending if the rate of value emissions is equal for all three observables the .zip() operator might do what you need: 根据所有三个可观察值的发射率是否相等, .zip()运算符可能会执行您需要的操作:
const idStream = myObservableOne.pluck('id')
const nameStream = myObservableSecond.pluck('name')
const pathStream = myObservableThird.pluck('path')
Rx.Observable.zip(
idStream,
nameStream,
pathStream,
(id, name, path) => ({ id, name, path})
)
.subscribe(console.log);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.