У меня проблемы с реализацией rx js v6 и rxjs / operator:
import { Observable } from 'rxjs';
import { Subject } from 'rxjs';
import { startWith, debounceTime } from 'rxjs/operators';
export class ProductListComponent implements OnInit {
public products$: Observable<Product[]>;
public searchTerm: string = '';
private searchSubject: Subject<string> = new Subject();
private reloadProductsList: Subject<void> = new Subject();
constructor(private productService: ProductService) { }
ng OnInit() {
this.products$ = this.searchSubject
.pipe(startWith(this.searchTerm), debounceTime(300));
}
...
}
Указанная ошибка c связана с this.products$
in ngOnInit()
. Вот ошибка:
Type 'Observable<string | Product[]>' is not assignable to type 'Observable<Product[]>'.
Type 'string | Product[]' is not assignable to type 'Product[]'.
Type 'string' is not assignable to type 'Product[]'
Ошибка меня смущает. Вы можете помочь?