我相信你只要一个
forkJoin
. 尝试以下操作
forkJoin([
this.getTranslation('snackbars.username.success.title'),
this.getTranslation('snackbars.username.success.body')
]).subscribe(
response => {
console.log('here', response[0], response[1]);
this.snackBarService.open(response[0], response[1]);
}
);
叉接
只有当两个观测都完成时才发射。如果没有,你可以用
combineLatest
在一个
take(1)
仅使用从可观测数据中发出的第一个值并完成。
combineLatest([
this.getTranslation('snackbars.username.success.title'),
this.getTranslation('snackbars.username.success.body')
]).pipe(
take(1)
).subscribe(
response => {
console.log('here', response[0], response[1]);
this.snackBarService.open(response[0], response[1]);
}
);