我正在从我的服务获取数据,并且我对订阅后取消订阅的重要性感到愤怒,这就是我的做法:
export class RItemComponent implements OnInit {
apiPath = environment.apiUrl;
private ngUnsubscribe: Subject = new Subject();
constructor(private _sharedService: SharedService) { }
rItems: Product[];
ngOnInit() {
this._sharedService.
getReceiptItem().takeUntil(this.ngUnsubscribe).
subscribe(products => this.rItems = products);
}
ngOnDestroy() {
this.ngUnsubscribe.next();
this.ngUnsubscribe.complete();
}
}
但现在我收到一个错误:
Generic type Subject<T> requires 1 type argument(s). subscribe
我不明白为什么?
任何形式的帮助都会很棒,谢谢!
为主题添加通用类型
private ngUnsubscribe: Subject<any> = new Subject();
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)