Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 如何等待来自不同观察对象的数据执行操作_Angular_Redux_Rxjs_Ngrx - Fatal编程技术网

Angular 如何等待来自不同观察对象的数据执行操作

Angular 如何等待来自不同观察对象的数据执行操作,angular,redux,rxjs,ngrx,Angular,Redux,Rxjs,Ngrx,我的英语有问题。我想从各种可观测数据中获取数据,并在所有数据到达后采取行动 我已经分别尝试了获取address和data Person的方法,如果它们工作正常,我会将示例留给获取address的案例 getDireccion() { this.store .select('direccion') .subscribe(({ direccion }) => (this.direccion = direccion)) .unsubscri

我的英语有问题。我想从各种可观测数据中获取数据,并在所有数据到达后采取行动

我已经分别尝试了获取address和data Person的方法,如果它们工作正常,我会将示例留给获取address的案例

getDireccion() {
    this.store
        .select('direccion')
        .subscribe(({ direccion }) => (this.direccion = direccion))
        .unsubscribe();
}
但是现在我想确保所有的地址数据和个人数据都已经存在,以便能够执行另一个操作,这就是为什么我使用forkJoin,但它对我不起作用,它不执行
console.log('responses==>',response)


我正在使用ngrx进行状态处理

如果您想在组件生命周期内更改某项操作,或者只使用
take(1)
选择一次,则应使用
CombineTest
。它不起作用的原因是,
forkJoin
等待可观察对象完成,而存储
select
从未真正完成:

combineLatest([ 
    this.store.select('direccion'),
    this.store.select('datosPersona')
]).subscribe((response) => {
    console.log('respuestas ==> ', response);
});


Esta pagina es para ingles,si puede cambiar la成语nos podemos Ayudaretry使用英语是一个纯英语网站-请遵守网站规则,将您的问题(包括标题!)翻译成英语,或者将其发布在
combineLatest([ 
    this.store.select('direccion'),
    this.store.select('datosPersona')
]).subscribe((response) => {
    console.log('respuestas ==> ', response);
});
forkJoin([ 
    this.store.select('direccion').pipe(take(1)),
    this.store.select('datosPersona').pipe(take(1))
]).subscribe((response) => {
    console.log('respuestas ==> ', response);
});