Skip to content

ДЗ #3 Параметры для дочерних компонентов и событие добавления в корзину #50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: lecture-3
Choose a base branch
from

Conversation

vakulovv
Copy link

No description provided.

@vakulovv vakulovv changed the title feat: add pass props to child and emit parent to cart event ДЗ #3 Параметры для дочерних компонентов и событие для добавления в корзину Nov 13, 2023
@vakulovv vakulovv changed the title ДЗ #3 Параметры для дочерних компонентов и событие для добавления в корзину ДЗ #3 Параметры для дочерних компонентов и событие добавления в корзину Nov 13, 2023
Copy link
Owner

@Letto228 Letto228 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Привет!
Все гуд 👍, оставил пару комментариев, буду ждать твоего ответа по ним!


onProductBuy(event: Event) {
@Output() readonly buyClick: EventEmitter<string> = new EventEmitter<string>();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не кажется ли тебе, что получается тавтология?)

...: EventEmitter<string> = new EventEmitter<string>();

Есть ли в этом сакральный смысл?

Мне кажется, что нет, тут отлично сработала бы неявная типизация свойства, а за счет дженерика можно четко указать тип данных передающихся в Output:

@Output() readonly productBuy = new EventEmitter<string>();

Эта запись мне видится лаконичней, без тавтологии, и не менее типизированной, что важно.

Что думаешь по данному поводу?

@@ -1,13 +1,17 @@
import {Component} from '@angular/core';
import {IProduct} from 'src/app/shared/products/product.interface';
import {productsMock} from 'src/app/shared/products/products.mock';
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Почему использовал абсолютные пути?


@Component({
selector: 'app-products-list',
templateUrl: './products-list.component.html',
styleUrls: ['./products-list.component.css'],
})
export class ProductsListComponent {
onCardClick() {
products: IProduct[] = productsMock;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я бы тут рекомендовал убрать явную типизацию, т.к. в ней нет особого смысла: она ни читаемости особой не добавляет, ни типизацию не ужесточает, т.к. через механизм неявной типизации - свойство products сможет отлично унаследовать тип константы productsMock

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants