Псевдокод не могу понять как внутри pipe использовать filter map и include? В доках нашёл
Use the pipe() function to make new operators но я не понимаю как передать параметры (v)?
import { pipe, filter, map } from 'rxjs';
function discardOddDoubleEven() {
return pipe(
filter((v) => !(v % 2)),
map((v) => v + v)
);
}
Не работает
this.productsService
.findAll()
.pipe(map(data).filter(data).include())
.subscribe((data: ProductInterface[]) => (this.products = data));
Работает
import { Component, OnInit } from '@angular/core';
import { ProductInterface } from 'src/app/interfaces/product.Interface';
import { ProductsService } from 'src/app/services/products.service';
@Component({
selector: 'page-products',
templateUrl: './products.page.html',
})
export class ProductsPage implements OnInit {
public products!: ProductInterface[];
public constructor(private readonly productsService: ProductsService) {}
private categoryFilter() {
return this.products.filter((product) =>
product.name.toLocaleLowerCase().includes('deepcool')
);
}
private findAll(): void {
this.productsService
.findAll()
.subscribe((data: ProductInterface[]) => (this.products = data));
}
public ngOnInit(): void {
this.productsService
.findAll()
.subscribe(
(data: ProductInterface[]) =>
(this.products = data.filter((product) =>
product.name.toLocaleLowerCase().includes('deepcool')
))
);
}
}