-
Notifications
You must be signed in to change notification settings - Fork 15
ДЗ по лекции #11 #117
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
base: lecture-11
Are you sure you want to change the base?
ДЗ по лекции #11 #117
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Привет!
В целом все гуд, но есть пару вопросов/рекомендаций. Посмотри пожалуйста, буду ждать от тебя фидбека!)
priceRange: { | ||
min: number; | ||
max: number; | ||
name?: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Немного духоты по семантике от Егора: судя по коду - поля не опциональные - они будут иметь либо указанное в них значение, либо undefinde
, но они точно будут определены в объекте. По этому корректней указать name: string | undefined
, если я все правильно понял
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Привет! Не смог разобраться, почему поля не могут быть опциальными. Ведь если юзер вручную отредактирует URL в браузере с параметрами и удалит часть параметров или например перейдет на путь /products-list
без параметров, то объект filter
в FilterComponent
не будет иметь какое-то поле или будет вообще пустым.
} | ||
|
||
updateFilterForm() { | ||
this.updateBrandsControl(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Кажется, что в каком то кейсе мы будем вызывать updateBrandsControl
за один ngOnChanges
несколько раз, лучше в таком случае немного поменять условие в ngOnChnges
:
ngOnChanges({brands, filter}: SimpleChanges) {
if (brands || filter) {
this.updateBrandsControl();
}
А в updateFilterForm
updateBrandsControl
не вызывать
Кстати, а почему метод решил сделать публичным?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Спасибо! Понял, что ошибся в логике. Исправил. Метод сделал публичным не специально, забыл указать private
.
map(filterFormValues => { | ||
return this.processFilterFormValues(filterFormValues); | ||
}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
map(filterFormValues => { | |
return this.processFilterFormValues(filterFormValues); | |
}), | |
map(filterFormValues => this.processFilterFormValues(filterFormValues)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Спасибо! Поправил
const productsFilter = { | ||
...filterFormValues, | ||
brands: sanitizedBrands, | ||
} as IProductsFilter; | ||
|
||
return productsFilter; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const productsFilter = { | |
...filterFormValues, | |
brands: sanitizedBrands, | |
} as IProductsFilter; | |
return productsFilter; | |
return productsFilter = { | |
...filterFormValues, | |
brands: sanitizedBrands, | |
} as IProductsFilter; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Здесь тоже исправил)
trackById(_index: number, {_id}: IProduct) { | ||
return _id; | ||
} | ||
|
||
listenQueryParamsChange() { | ||
this.activatedRoute.queryParams.subscribe(params => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Почему метод публичный? И почему не захотел использовать AsyncPipe
?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
По AsyncPipe
у меня как-то отложилось в голове, что | async
лучше использовать для вывода каких-то данных в компоненте, а не для передачи между компонентами, т.е. я в принципе, изначально и не рассматривал такой вариант. Переделал. Думаю, лучше с async
. Правда теперь у меня сомнения, не слишком ли громоздким получается шаблон компонента из-за дополнительного ng-container
'а.
Публичным метод сделал опять же не специально, забыл. Исправил.
|
||
updateProductsFilter(productsFilter: IProductsFilter) { | ||
this.router.navigate([''], { | ||
relativeTo: this.activatedRoute, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Отличное решение!
No description provided.