Skip to content

Task-9#8

Open
YurikMurik wants to merge 2 commits intotask-8from
task-9
Open

Task-9#8
YurikMurik wants to merge 2 commits intotask-8from
task-9

Conversation

@YurikMurik
Copy link
Copy Markdown
Owner

  • changed searchbox logic (added debounce, filter by input value, etc.)
  • changed logic of auth guard service (now it returns observables)
  • created global loading block and implemented it for all requests in the app

- changed searchbox logic (added debounce, filter by input value, etc.)
- changed logic of auth guard service (now it returns observables)
- created global loading block and implemented it for all requests in the app
Comment thread src/app/core/services/auth.service.ts Outdated
switchMap(() => {
return this.isAuthentificated()
.pipe(
map(auth => auth)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

what is the point in adding this operator?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

this is an unnecessary piece of code. I deleted it

Comment thread src/app/core/services/auth.service.ts Outdated

public getUserInfo(): Observable<UserInfo> {
return this.http.get<UserInfo>(this.userUrl);
this.loadingBlockService.updateLoadingBlockState('start');
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It would be better to work with booleans instead of strings 'start' and 'finish'

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

fixed

Comment thread src/app/root/app.component.ts Outdated
this.loadingBlockService.stateLoadingBlockNotify.subscribe(
state => {
this.loadingState = state;
this.cdref.detectChanges();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

why do you need this if your component uses the default change detection strategy?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

it's mistake, fixed. there is another way for subscribing on loader's component changes

}

public getDataFromApi(): void {
if (this.searchInput.length === 0 || this.searchInput.length >= 3) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

it would be better to add this functionality with filter rxjs operator

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

fixed

this.searchInputChange
.pipe(debounceTime(1000), distinctUntilChanged())
.subscribe(result => {
this.searchInput = result;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

why would you need this assignment?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

fixed

.pipe(debounceTime(1000), distinctUntilChanged())
.subscribe(result => {
this.searchInput = result;
this.getDataFromApi();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

implement this functionality using mergeMap

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

completed

public stateLoadingBlockNotify: Observable<boolean> = this.notificationSource.asObservable();

public updateLoadingBlockState(newState: string): void {
this.notificationSource.next(this.initialState);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

why?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

fixed

})

export class LoadingBlockService {
private notificationSource: Subject<boolean> = new Subject();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

use type of subject you can pass the initial value to

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

fixed

- Fixed comments
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