Created
July 16, 2020 13:32
-
-
Save codewithsrini/2aae47073072b12cd21484aae47b61f9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="page-overlay-wrapper" *ngIf="showSpinner"> | |
<div class="bee-spinner"></div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@keyframes bouncing { | |
0% { | |
top: 40%; | |
} | |
100% { | |
top: 30%; | |
} | |
} | |
@keyframes fadein { | |
0% { | |
opacity: 0; | |
} | |
100% { | |
opacity: 1; | |
} | |
} | |
.page-overlay-wrapper { | |
position: fixed; | |
width: 100%; | |
height: 100%; | |
top: 0; | |
z-index: 1009; | |
background: rgba(112, 191, 93, 0.5); | |
.bee-spinner { | |
width: 20%; | |
height: 20%; | |
position: fixed; | |
top: 40%; | |
left: calc(50% - 10%); | |
z-index: 100; | |
background-image: url(../../assets/bee-spinner.png); | |
background-repeat: no-repeat; | |
background-size: 97%; | |
animation: bouncing 0.4s cubic-bezier(0.1, 0.25, 0.1, 1) 0s infinite | |
alternate both; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, OnInit, ChangeDetectorRef } from '@angular/core'; | |
import { SpinnerService } from './spinner.service'; | |
@Component({ | |
selector: 'app-spinner', | |
templateUrl: './spinner.component.html', | |
styleUrls: ['./spinner.component.scss'] | |
}) | |
export class SpinnerComponent implements OnInit { | |
showSpinner = false; | |
constructor(private spinnerService: SpinnerService, private cdRef: ChangeDetectorRef) { | |
} | |
ngOnInit() { | |
this.init(); | |
} | |
init() { | |
this.spinnerService.getSpinnerObserver().subscribe((status) => { | |
this.showSpinner = (status === 'start'); | |
this.cdRef.detectChanges(); | |
}); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@angular/core'; | |
import { BehaviorSubject, Observable } from 'rxjs'; | |
@Injectable({ | |
providedIn: 'root' | |
}) | |
export class SpinnerService { | |
private count = 0; | |
private spinner$ = new BehaviorSubject<string>(''); | |
constructor() { } | |
getSpinnerObserver(): Observable<string> { | |
return this.spinner$.asObservable(); | |
} | |
requestStarted() { | |
if (++this.count === 1) { | |
this.spinner$.next('start'); | |
} | |
} | |
requestEnded() { | |
if (this.count === 0 || --this.count === 0) { | |
this.spinner$.next('stop'); | |
} | |
} | |
resetSpinner() { | |
this.count = 0; | |
this.spinner$.next('stop'); | |
} | |
} |
Can I get the code for http-error. Interceptor and index.ts.. Please
For interceptor code, you can go through the youtube video
Link - https://www.youtube.com/watch?v=H9KLIbisVJ8&t=909s
please! provide http interceptor code also, its hard to read it and write it
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello, Please I do not understand what you did in your interceptor file. Can you help me with the codes for better clarifications.