我正在尝试实现一个方法,该方法返回一个布尔值的 observable,如果另一个 observable 包含真实值,则该值为 true。这是大部分的实现:
/**
* Observe changes to the values.
*
* @param key
* @return An {@link Observable<boolean>} indicating whether the value exists.
*/
public exists(key:string) {
if (!this.subjects[key]) {
throw new Error(`No subject exists for the key ${key}`);
}
return this.subjects[key].asObservable().pipe(???);
}
是否存在执行value != null
检查的操作员?类似于isDefined
操作员的东西?
map(value => !!value)
没有将某些值转换为布尔值的运算符。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句