我正在尝试使用返回的observable类型将observable分配给类属性。
执行此操作不能像obs $那样充当隐式类型any:
export class Service {
public obs$;
constructor() {
this.obs$ = combineLatest(
this.store.pipe(select(selectAllData)),
this.store.pipe(select(selectRowCount)),
this.store.pipe(select(selectTotal)),
this.store.pipe(select(selectAnalyseElementIsFormattedValue)),
this.store.pipe(select(selectAnalyseComparisonOptions)),
(data, rowCount, total, isFormatted, comparisonOptions) => ({data, rowCount, total, isFormatted, comparisonOptions})
).pipe(
withLatestFrom(
this.store.pipe(select(selectCurrentPage)),
this.store.pipe(select(selectCurrentPeriod)),
this.store.pipe(select(selectMaxResult)),
this.store.pipe(select(selectIsComparison)),
(combine, currentPage, currentPeriod, maxResult, isComparison) => ({...combine, currentPage, currentPeriod, maxResult, isComparison})
),
filter(dataTable => !!dataTable.data)
);
}
我发现用其类型创建可观察属性的唯一方法 就是这样,但我不想这么做...:
public analyseDataTable$ = combineLatest(
this.store.pipe(select(selectAllData)),
this.store.pipe(select(selectRowCount)),
this.store.pipe(select(selectTotal)),
this.store.pipe(select(selectAnalyseElementIsFormattedValue)),
this.store.pipe(select(selectAnalyseComparisonOptions)),
(data, rowCount, total, isFormatted, comparisonOptions) => ({data, rowCount, total, isFormatted, comparisonOptions})
).pipe(
withLatestFrom(
this.store.pipe(select(selectCurrentPage)),
this.store.pipe(select(selectCurrentPeriod)),
this.store.pipe(select(selectMaxResult)),
this.store.pipe(select(selectIsComparison)),
(combine, currentPage, currentPeriod, maxResult, isComparison) => ({...combine, currentPage, currentPeriod, maxResult, isComparison})
),
filter(dataTable => !!dataTable.data)
);
}
有什么方法可以从构造函数分配类型推导到定义的属性类?
谢谢