-
Notifications
You must be signed in to change notification settings - Fork 140
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
Закончил задачу джуна переписать на NGRX #105
base: master
Are you sure you want to change the base?
Conversation
src/app/user-list/edit-user-dialog/edit-user-dialog.component.ts
Outdated
Show resolved
Hide resolved
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.
некоторые комментарии не исправлены
src/app/app.component.ts
Outdated
|
||
@Component({ | ||
selector: 'app-root', | ||
standalone: true, | ||
imports: [RouterOutlet], | ||
imports: [RouterOutlet, UserListComponent], |
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.
Корректное название для компоненты UsersListComponent, так как это список пользователей (множ. число)
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.
сделано
src/app/services/users.service.ts
Outdated
|
||
loadUser(): void { | ||
this.usersApiService.getUsers() | ||
.pipe(takeUntil(this.destroy$)) // Отписка при уничтожении |
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.
удалите комментарии везде
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.
сделано
import { createSelector } from '@ngrx/store'; | ||
import { User } from "../../types/user.types"; | ||
|
||
interface UserState { |
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.
в файле users.selectors тип называется UserState?
Пользователи во множ.числе UsersState нужно
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.
сделано
src/app/services/users.service.ts
Outdated
providedIn: 'root' | ||
}) | ||
export class UsersService implements OnDestroy { | ||
private userSubject = new BehaviorSubject<User[]>([]); |
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.
добавляйте readonly по надобности
inject рядом с inject
BehaviorSubject рядом с BehaviorSubject
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.
сделал
src/app/services/users.service.ts
Outdated
editUser(editedUser: User) { | ||
const users = this.userSubject.value.map(user => | ||
user.id === editedUser.id ? editedUser : user | ||
); |
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.
пустуй строку добавьте перед this.userSubject.next(users);, чтобы визуально отделить логику
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.
сделал
src/app/services/users.service.ts
Outdated
} | ||
|
||
createUser(newUser: User) { | ||
const users = [...this.userSubject.value, newUser]; |
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.
пустуй строку добавьте перед this.userSubject.next(users);чтобы визуально отделить логику
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.
сделал
import {Component} from "@angular/core"; | ||
import {FormControl, FormGroup, ReactiveFormsModule, Validators} from "@angular/forms"; | ||
import {NgIf} from "@angular/common"; | ||
import {MatDialogClose} from "@angular/material/dialog"; |
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.
не сделано, установите prettier
import {Component} from "@angular/core"; | ||
import {FormControl, FormGroup, ReactiveFormsModule, Validators} from "@angular/forms"; | ||
import {NgIf} from "@angular/common"; | ||
import {MatDialogClose} from "@angular/material/dialog"; |
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.
https://youtu.be/__eiQumLOEo?si=wwTbSKNncaMelG-R видео по prettier
}); | ||
|
||
dialogRef.afterClosed().subscribe(editResult => { | ||
if (!editResult) return; |
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.
если после return, есть код, то ставьте пустую строку
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.
сделано
}) | ||
|
||
export class UsersListComponent { | ||
public readonly store = inject(Store); |
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.
вы уверены что все 3 зависимости public? поставьте каждому private и если работает, оставьте private
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.
сделал
providedIn: 'root', | ||
}) | ||
export class UsersService implements OnDestroy { | ||
private readonly userSubject = new BehaviorSubject<User[]>([]) |
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.
в названии для subject нужно добавлять $ это общепринятая практика, что бы указать визуально что это поток
telegram @nurtuganulyn