获取可观察的RXJ内观察的价值
我在字段
属性中可观察到以下可观察到的
config$: Observable<QueryBuilderConfig>;
this.config$.pipe(map(item => {
return {
fieldGroups: [
{ id: CustomAttributeEntityType.Risk, label: this.l('Risk') },
{ id: CustomAttributeEntityType.RiskAssessment, label: this.l('Risk Assessment') }
],
fields: this.metricCreateConfigureStore.queryBuilderFields$, // Get the value from obserable
allowEmptyRules: true,
allowEmptyRulesets: false
}
}));
属性,我想从另一个可观察的可观察的值中获取值,例如
fields: this.metricCreateConfigureStore.queryBuilderFields$
querybuilderfields $
return observable 如下
readonly queryBuilderFields$: Observable<{ [key: string]: QueryBuilderFieldsDto }> = this.select(state => state.queryBuilderFields);
如何我可以获得价值,而无需在那儿订阅吗?
I have below Observable
config$: Observable<QueryBuilderConfig>;
this.config$.pipe(map(item => {
return {
fieldGroups: [
{ id: CustomAttributeEntityType.Risk, label: this.l('Risk') },
{ id: CustomAttributeEntityType.RiskAssessment, label: this.l('Risk Assessment') }
],
fields: this.metricCreateConfigureStore.queryBuilderFields$, // Get the value from obserable
allowEmptyRules: true,
allowEmptyRulesets: false
}
}));
In the field
attribute, I want to get the value from another observable, something like below
fields: this.metricCreateConfigureStore.queryBuilderFields$
queryBuilderFields$
return Observable
as below
readonly queryBuilderFields$: Observable<{ [key: string]: QueryBuilderFieldsDto }> = this.select(state => state.queryBuilderFields);
How can I get the value, without subscribe over there??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
取决于您确切地含义的“来自其他可观察到的价值”的含义:两个流独立发射,您想从两者中捕获值吗?那就是
或使用一个流的值来创建另一个流?那是
switchmap
(或者也许是其兄弟姐妹之一,例如concatmap
,mergemap
等):Depends on what you exactly mean by "value from other observable": two streams emitting independently, and you want to catch values from both? That's
Or use value from one stream to create another one? That's
switchMap
(or maybe one of its siblings, likeconcatMap
,mergeMap
etc.):那将是类似的东西
,而且我不会在流操作中使用
this.l()
函数调用,而是要使用要使用的参数,所以纯粹的函数。That would be something like
And also, I would not use
this.l()
function call inside the stream handlind, but put a parameter to be used, so pure function.