Skip to content

Service, interceptor, models and testing component#2

Open
borisjotic wants to merge 4 commits into
mainfrom
feat/loader-interceptor-service
Open

Service, interceptor, models and testing component#2
borisjotic wants to merge 4 commits into
mainfrom
feat/loader-interceptor-service

Conversation

@borisjotic

@borisjotic borisjotic commented Nov 3, 2022

Copy link
Copy Markdown
Owner

Notable files:

  • src/app/core/interceptors/http-loader.interceptor.ts -> will intecept request(s) and show/hide loader (main or dedicated)
  • src/app/core/services/loader-state.service.ts -> the service for loader, all logic is placed here with aditional utility methods (for dedicated/no loader scenario)
  • src/app/shared/enums/header-name.enum.ts -> enum for headers used by interceptor/service
  • src/app/shared/models/loader-header.model.ts -> type representing header used by interceptor/service to determin type of loader to show

Usage examples could be found in src/app/loader-test/loader-test.component.ts:171-237

@borisjotic borisjotic changed the title service, interceptor, models and testing component Service, interceptor, models and testing component Nov 4, 2022
const requestIgnored =
this.requestForIgnore.filter((ignoreReq) =>
ignoreReq.toLowerCase().endsWith(url)
).length === 0;

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 !! instead of === 0

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.

With that change, we'll get a bit different if statement bellow and with it everything...

const requestNotIgnored = !!(...).length;

if(requestNotIgnoired) {
  return output;
}

return null;

Should I proceed?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

for your logic you need to use !, but in general use conversion to boolean, not comparation with 0

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.

yy, the !! consfused me, change is comming ;)

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