请问,如下方法的作用是什么?
这是用rxjs处理表单的一段代码.
private propagateChange = (_: any) => {};
ngOnInit() {
const idType$ = this.idType;
const idNo$ = this.idNo;
const val$ = Observable.combineLatest(idType$, idNo$, (_type, _no) => {
return {
identityType: _type,
identityNo: _no
};
});
this._sub = val$.subscribe(v => {
this.identity = v;
this.propagateChange(v); //调用
});
}
public registerOnChange(fn: any) {
this.propagateChange = fn; //调用
}
这里不是重写了吗,应该是在业务中预先定义了
propagateChange
,而该函数是由外部使用者来定义的,所以写了空的,等待后面使用registerOnChange
函数重写