Skip to content

Commit c13bfd1

Browse files
committed
Rename SpinnerComponent to NgHttpLoaderComponent and rename component selector to 'ng-http-loader'
1 parent 2e9216b commit c13bfd1

File tree

7 files changed

+43
-43
lines changed

7 files changed

+43
-43
lines changed

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ $ npm install ng-http-loader --save / yarn add ng-http-loader
2323

2424
## What does it do ?
2525

26-
This package provides an HTTP Interceptor, and a spinner component (All from [SpinKit](https://github.com/tobiasahlin/SpinKit) at the moment).
26+
This package provides an HTTP Interceptor, and some spinner components (All from [SpinKit](https://github.com/tobiasahlin/SpinKit) at the moment).
2727
The HTTP interceptor listens to all HTTP requests and shows a spinner / loader indicator during pending http requests.
2828

2929
## Angular 4 / Angular 5 / Angular 6
@@ -74,19 +74,19 @@ export class AppModule { }
7474

7575
In your app.component.html, simply add:
7676
```xml
77-
<spinner></spinner>
77+
<ng-http-loader></ng-http-loader>
7878
```
7979

8080
## Customizing the spinner
8181

8282
You can customize the **background-color**, the **spinner type**, the **debounce delay** (ie. after how many milliseconds the spinner will be visible, if needed), the **minimum duration** (ie. how many milliseconds should the spinner be visible at least):
8383
```xml
84-
<spinner
84+
<ng-http-loader
8585
[backgroundColor]="'#ff0000'"
8686
[spinner]="spinkit.skWave"
8787
[debounceDelay]="100"
8888
[minDuration]="300">
89-
</spinner>
89+
</ng-http-loader>
9090
```
9191

9292
**_To use this syntax, you must reference the ``Spinkit`` const as a public property in your app.component.ts_**:
@@ -110,7 +110,7 @@ The different spinners available are referenced in [this class](src/lib/spinkits
110110
**_Otherwise, you can simply reference the chosen spinner as a simple string_**:
111111

112112
```xml
113-
<spinner backgroundColor="#ff0000" spinner="sk-wave"></spinner>
113+
<ng-http-loader backgroundColor="#ff0000" spinner="sk-wave"></ng-http-loader>
114114
```
115115

116116
## Defining your own spinner
@@ -120,9 +120,9 @@ You can define your own loader component in place of the built-in ones. The need
120120
- Create your component
121121
- Add it to the [entryComponent](https://angular.io/guide/ngmodule-faq#what-is-an-entry-component) definition in your module definition
122122
- Reference your component in a public property in your ``app.component.ts``
123-
- Reference the property in the spinner component like this:
123+
- Reference the property in the ng-http-loader component like this:
124124
```xml
125-
<spinner [entryComponent]="myAwesomeComponent"></spinner>
125+
<ng-http-loader [entryComponent]="myAwesomeComponent"></ng-http-loader>
126126
```
127127

128128
You can find some short examples [here](https://gist.github.com/mpalourdio/2c0bec03d610b24ff49db649fbb69a48) and [here](https://gist.github.com/mpalourdio/e05b4495de2abeeecfcf92d70e4ef93e).
@@ -131,22 +131,22 @@ You can find some short examples [here](https://gist.github.com/mpalourdio/2c0be
131131

132132
You can filter the http requests that shouldn't be caught by the interceptor by providing **an array of regex patterns**:
133133
```xml
134-
<spinner [filteredUrlPatterns]="['\\d', '[a-zA-Z]', 'my-api']"></spinner>
134+
<ng-http-loader [filteredUrlPatterns]="['\\d', '[a-zA-Z]', 'my-api']"></ng-http-loader>
135135
```
136136

137137
You can filter the http requests by providing **an array of HTTP methods** (case insensitive):
138138
```xml
139-
<spinner [filteredMethods]="['gEt', 'POST', 'PuT']"></spinner>
139+
<ng-http-loader [filteredMethods]="['gEt', 'POST', 'PuT']"></ng-http-loader>
140140
```
141141

142142
You can also filter the http requests by providing **an array of HTTP headers** (case insensitive):
143143
```xml
144-
<spinner [filteredHeaders]="['hEaDeR', 'AnoTheR-HeAdEr']"></spinner>
144+
<ng-http-loader [filteredHeaders]="['hEaDeR', 'AnoTheR-HeAdEr']"></ng-http-loader>
145145
```
146146

147147
## Manually show and hide the spinner
148148

149-
You can manually show and hide the spinner component if needed. You must use the ``SpinnerVisibilityService`` for this purpose.
149+
You can manually show and hide the spinner if needed. You must use the ``SpinnerVisibilityService`` for this purpose.
150150

151151
Sometimes, when manually showing the spinner, an http request could be performed in background, and when finished, the spinner would automagically disappear.
152152

File renamed without changes.
File renamed without changes.

src/lib/components/spinner/spinner.component.ts renamed to src/lib/components/ng-http-loader.component.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@
1010
import { Component, Input, OnDestroy, OnInit } from '@angular/core';
1111
import { EMPTY, merge, Observable, Subscription, timer } from 'rxjs';
1212
import { debounce, delayWhen } from 'rxjs/operators';
13-
import { PendingInterceptorService } from '../../services/pending-interceptor.service';
14-
import { SpinnerVisibilityService } from '../../services/spinner-visibility.service';
15-
import { Spinkit } from '../../spinkits';
13+
import { PendingInterceptorService } from '../services/pending-interceptor.service';
14+
import { SpinnerVisibilityService } from '../services/spinner-visibility.service';
15+
import { Spinkit } from '../spinkits';
1616

1717
@Component({
18-
selector: 'spinner',
19-
templateUrl: './spinner.component.html',
20-
styleUrls: ['./spinner.component.css']
18+
selector: 'ng-http-loader',
19+
templateUrl: './ng-http-loader.component.html',
20+
styleUrls: ['./ng-http-loader.component.css']
2121
})
22-
export class SpinnerComponent implements OnDestroy, OnInit {
22+
export class NgHttpLoaderComponent implements OnDestroy, OnInit {
2323
public isSpinnerVisible: boolean;
2424
public spinkit = Spinkit;
2525
private subscriptions: Subscription;

src/lib/ng-http-loader.module.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,21 @@
1010
import { CommonModule } from '@angular/common';
1111
import { HttpClientModule } from '@angular/common/http';
1212
import { NgModule } from '@angular/core';
13-
import { SpinnerComponent } from './components/spinner/spinner.component';
13+
import { NgHttpLoaderComponent } from './components/ng-http-loader.component';
1414
import { PendingInterceptorServiceInterceptor } from './services/pending-interceptor.service';
1515
import { SPINKIT_COMPONENTS } from './spinkits';
1616

1717
@NgModule({
1818
declarations: [
19-
SpinnerComponent,
19+
NgHttpLoaderComponent,
2020
SPINKIT_COMPONENTS,
2121
],
2222
imports: [
2323
CommonModule,
2424
HttpClientModule,
2525
],
2626
exports: [
27-
SpinnerComponent,
27+
NgHttpLoaderComponent,
2828
SPINKIT_COMPONENTS,
2929
],
3030
providers: [

src/test/components/spinner/spinner.component.outlet.spec.ts renamed to src/test/components/ng-http-loader.component.outlet.spec.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@ import { HttpClientTestingModule } from '@angular/common/http/testing';
1111
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
1212
import { By } from '@angular/platform-browser';
1313
import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing';
14-
import { SkThreeBounceComponent } from '../../../lib/components/sk-three-bounce/sk-three-bounce.component';
15-
import { SpinnerComponent } from '../../../lib/components/spinner/spinner.component';
16-
import { PendingInterceptorServiceInterceptor } from '../../../lib/services/pending-interceptor.service';
17-
import { SPINKIT_COMPONENTS } from '../../../lib/spinkits';
14+
import { NgHttpLoaderComponent } from '../../lib/components/ng-http-loader.component';
15+
import { SkThreeBounceComponent } from '../../lib/components/sk-three-bounce/sk-three-bounce.component';
16+
import { PendingInterceptorServiceInterceptor } from '../../lib/services/pending-interceptor.service';
17+
import { SPINKIT_COMPONENTS } from '../../lib/spinkits';
1818

19-
describe('SpinnerComponentOutlet', () => {
20-
let component: SpinnerComponent;
21-
let fixture: ComponentFixture<SpinnerComponent>;
19+
describe('NgHttpLoaderComponentOutlet', () => {
20+
let component: NgHttpLoaderComponent;
21+
let fixture: ComponentFixture<NgHttpLoaderComponent>;
2222

2323
beforeEach(async(() => {
2424
TestBed.configureTestingModule({
25-
declarations: [SpinnerComponent, SPINKIT_COMPONENTS],
25+
declarations: [NgHttpLoaderComponent, SPINKIT_COMPONENTS],
2626
imports: [HttpClientTestingModule],
2727
providers: [PendingInterceptorServiceInterceptor]
2828
})
@@ -33,7 +33,7 @@ describe('SpinnerComponentOutlet', () => {
3333
}));
3434

3535
beforeEach(() => {
36-
fixture = TestBed.createComponent(SpinnerComponent);
36+
fixture = TestBed.createComponent(NgHttpLoaderComponent);
3737
component = fixture.componentInstance;
3838
});
3939

src/test/components/spinner/spinner.component.spec.ts renamed to src/test/components/ng-http-loader.component.spec.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,34 +12,34 @@ import { HttpClientTestingModule, HttpTestingController } from '@angular/common/
1212
import { async, ComponentFixture, fakeAsync, inject, TestBed, tick } from '@angular/core/testing';
1313
import { By } from '@angular/platform-browser';
1414
import { forkJoin, Observable } from 'rxjs';
15-
import { SpinnerComponent } from '../../../lib/components/spinner/spinner.component';
16-
import { PendingInterceptorServiceInterceptor } from '../../../lib/services/pending-interceptor.service';
17-
import { SpinnerVisibilityService } from '../../../lib/services/spinner-visibility.service';
18-
import { Spinkit, SPINKIT_COMPONENTS } from '../../../lib/spinkits';
15+
import { NgHttpLoaderComponent } from '../../lib/components/ng-http-loader.component';
16+
import { PendingInterceptorServiceInterceptor } from '../../lib/services/pending-interceptor.service';
17+
import { SpinnerVisibilityService } from '../../lib/services/spinner-visibility.service';
18+
import { Spinkit, SPINKIT_COMPONENTS } from '../../lib/spinkits';
1919

20-
describe('SpinnerComponent', () => {
21-
let component: SpinnerComponent;
22-
let fixture: ComponentFixture<SpinnerComponent>;
20+
describe('NgHttpLoaderComponent', () => {
21+
let component: NgHttpLoaderComponent;
22+
let fixture: ComponentFixture<NgHttpLoaderComponent>;
2323

2424
beforeEach(async(() => {
2525
TestBed.configureTestingModule({
26-
declarations: [SpinnerComponent, SPINKIT_COMPONENTS],
26+
declarations: [NgHttpLoaderComponent, SPINKIT_COMPONENTS],
2727
imports: [HttpClientTestingModule],
2828
providers: [PendingInterceptorServiceInterceptor]
2929
})
3030
.compileComponents();
3131
}));
3232

3333
beforeEach(() => {
34-
fixture = TestBed.createComponent(SpinnerComponent);
34+
fixture = TestBed.createComponent(NgHttpLoaderComponent);
3535
component = fixture.componentInstance;
3636
});
3737

38-
it('should create the spinner component', () => {
38+
it('should create the ng-http-loader component', () => {
3939
expect(component).toBeTruthy();
4040
});
4141

42-
it('should create the spinner component with default values', () => {
42+
it('should create the ng-http-loader component with default values', () => {
4343
component.isSpinnerVisible = true;
4444
fixture.detectChanges();
4545

@@ -123,7 +123,7 @@ describe('SpinnerComponent', () => {
123123
}
124124
)));
125125

126-
it('should hide and show a the spinner for a single HTTP request', fakeAsync(inject(
126+
it('should hide and show the spinner for a single HTTP request', fakeAsync(inject(
127127
[HttpClient, HttpTestingController], (http: HttpClient, httpMock: HttpTestingController) => {
128128
http.get('/fake').subscribe();
129129

@@ -279,7 +279,7 @@ describe('SpinnerComponent', () => {
279279
[HttpClient, HttpTestingController], (http: HttpClient, httpMock: HttpTestingController) => {
280280
http.get('/fake').subscribe();
281281

282-
const newFixture = TestBed.createComponent(SpinnerComponent);
282+
const newFixture = TestBed.createComponent(NgHttpLoaderComponent);
283283
const newComponent = newFixture.componentInstance;
284284

285285
tick();

0 commit comments

Comments
 (0)