Skip to content

Commit

Permalink
Merge 4b72b4b into 2410b65
Browse files Browse the repository at this point in the history
  • Loading branch information
mpalourdio committed Nov 22, 2018
2 parents 2410b65 + 4b72b4b commit f40a394
Show file tree
Hide file tree
Showing 10 changed files with 124 additions and 91 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## v4.0.0
`HttpClientModule` has been removed from imports. This caused some issues when external modules where imported in an application, and that those modules registered HTTP interceptors.

A static `forRoot()` has been added to the module declaration. You must now call this method when importing `NgHttpLoaderModule` in your root application module.
This intends to fix providers problems when working with lazy modules in which you would want to import `NgHttpLoaderModule`.

## v3.2.0

`peerDependencies` section now targets `angular 7`. The module is still `angular 6` compatible, so this is not a major release.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ import { NgHttpLoaderModule } from 'ng-http-loader'; // <============
imports: [
BrowserModule,
HttpClientModule, // <============ (Perform HTTP requests with this module)
NgHttpLoaderModule, // <============
NgHttpLoaderModule.forRoot(), // <============
],
providers: [],
bootstrap: [AppComponent]
Expand Down
24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"preversion": "yarn test",
"preversion": "yarn lint && yarn test",
"version": "yarn build",
"postversion": "git push && git push --tags"
},
Expand Down Expand Up @@ -36,21 +36,21 @@
"url": "https://github.com/mpalourdio/ng-http-loader/issues"
},
"peerDependencies": {
"@angular/common": "~7.0.0",
"@angular/core": "~7.0.0",
"@angular/common": "^7.1.0",
"@angular/core": "^7.1.0",
"rxjs": "~6.3.3"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.10.0",
"@angular-devkit/build-ng-packagr": "~0.10.0",
"@angular/cli": "~7.0.1",
"@angular/common": "~7.0.0",
"@angular/compiler": "~7.0.0",
"@angular/compiler-cli": "~7.0.0",
"@angular/core": "~7.0.0",
"@angular/language-service": "~7.0.0",
"@angular/platform-browser": "~7.0.0",
"@angular/platform-browser-dynamic": "~7.0.0",
"@angular/cli": "~7.0.5",
"@angular/common": "^7.1.0",
"@angular/compiler": "^7.1.0",
"@angular/compiler-cli": "^7.1.0",
"@angular/core": "^7.1.0",
"@angular/language-service": "^7.1.0",
"@angular/platform-browser": "^7.1.0",
"@angular/platform-browser-dynamic": "^7.1.0",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4",
Expand All @@ -68,7 +68,7 @@
"ng-packagr": "^4.2.0",
"rxjs": "~6.3.3",
"ts-node": "~7.0.0",
"tsickle": ">=0.29.0",
"tsickle": ">=0.34.0",
"tslib": "^1.9.0",
"tslint": "~5.11.0",
"typescript": "~3.1.6",
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/ng-http-loader.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class NgHttpLoaderComponent implements OnDestroy, OnInit {
public isSpinnerVisible: boolean;
public spinkit = Spinkit;
private subscriptions: Subscription;
private visibleUntil: number = Date.now();
private visibleUntil = Date.now();

@Input()
public backgroundColor: string;
Expand Down
15 changes: 9 additions & 6 deletions src/lib/ng-http-loader.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
*/

import { CommonModule } from '@angular/common';
import { HttpClientModule } from '@angular/common/http';
import { NgModule } from '@angular/core';
import { ModuleWithProviders, NgModule } from '@angular/core';
import { NgHttpLoaderComponent } from './components/ng-http-loader.component';
import { PendingInterceptorServiceInterceptor } from './services/pending-interceptor.service';
import { SPINKIT_COMPONENTS } from './spinkits';
Expand All @@ -21,15 +20,19 @@ import { SPINKIT_COMPONENTS } from './spinkits';
],
imports: [
CommonModule,
HttpClientModule,
],
exports: [
NgHttpLoaderComponent,
...SPINKIT_COMPONENTS,
],
providers: [
PendingInterceptorServiceInterceptor,
]
})
export class NgHttpLoaderModule {
static forRoot(): ModuleWithProviders {
return {
ngModule: NgHttpLoaderModule,
providers: [
PendingInterceptorServiceInterceptor,
]
};
}
}
9 changes: 8 additions & 1 deletion src/lib/services/pending-interceptor.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

import { HTTP_INTERCEPTORS, HttpErrorResponse, HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http';
import {
HTTP_INTERCEPTORS,
HttpErrorResponse,
HttpEvent,
HttpHandler,
HttpInterceptor,
HttpRequest
} from '@angular/common/http';
import { ExistingProvider, Injectable } from '@angular/core';
import { Observable, ReplaySubject, throwError } from 'rxjs';
import { catchError, finalize, map } from 'rxjs/operators';
Expand Down
2 changes: 1 addition & 1 deletion src/lib/services/spinner-visibility.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { PendingInterceptorService } from './pending-interceptor.service';
providedIn: 'root'
})
export class SpinnerVisibilityService {
private _visibilitySubject: ReplaySubject<boolean> = new ReplaySubject<boolean>(1);
private _visibilitySubject = new ReplaySubject<boolean>(1);

constructor(private pendingInterceptorService: PendingInterceptorService) {
}
Expand Down
5 changes: 5 additions & 0 deletions src/test/ng-http-loader.module.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,9 @@ describe('NgHttpLoaderModule', () => {
it('should create an instance', () => {
expect(ngHttpLoaderModule).toBeTruthy();
});

it('should work with forRoot', () => {
const moduleWithProviders = NgHttpLoaderModule.forRoot();
expect(moduleWithProviders).toBeTruthy();
});
});
5 changes: 4 additions & 1 deletion src/test/services/pending-interceptor.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ import { HttpClient, HttpErrorResponse } from '@angular/common/http';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { async, inject, TestBed } from '@angular/core/testing';
import { forkJoin, Observable } from 'rxjs';
import { PendingInterceptorService, PendingInterceptorServiceInterceptor } from '../../lib/services/pending-interceptor.service';
import {
PendingInterceptorService,
PendingInterceptorServiceInterceptor
} from '../../lib/services/pending-interceptor.service';

describe('PendingInterceptorService', () => {

Expand Down
Loading

0 comments on commit f40a394

Please sign in to comment.