ng-http-loader 16.0.0 → 17.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -59
- package/fesm2022/ng-http-loader.mjs +111 -143
- package/fesm2022/ng-http-loader.mjs.map +1 -1
- package/lib/components/abstract.loader.directive.d.ts +1 -1
- package/lib/components/ng-http-loader.component.d.ts +4 -4
- package/lib/components/sk-chasing-dots/sk-chasing-dots.component.d.ts +1 -1
- package/lib/components/sk-cube-grid/sk-cube-grid.component.d.ts +1 -1
- package/lib/components/sk-double-bounce/sk-double-bounce.component.d.ts +1 -1
- package/lib/components/sk-rotating-plane/sk-rotating-plane.component.d.ts +1 -1
- package/lib/components/sk-spinner-pulse/sk-spinner-pulse.component.d.ts +1 -1
- package/lib/components/sk-three-bounce/sk-three-bounce.component.d.ts +1 -1
- package/lib/components/sk-wandering-cubes/sk-wandering-cubes.component.d.ts +1 -1
- package/lib/components/sk-wave/sk-wave.component.d.ts +1 -1
- package/lib/services/{pending-requests-interceptor.service.d.ts → pending-requests-interceptor-configurer.service.d.ts} +11 -12
- package/lib/services/pending-requests-interceptor.d.ts +3 -0
- package/lib/services/spinner-visibility.service.d.ts +3 -3
- package/package.json +3 -5
- package/public_api.d.ts +2 -2
- package/esm2022/lib/components/abstract.loader.directive.mjs +0 -20
- package/esm2022/lib/components/ng-http-loader.component.mjs +0 -113
- package/esm2022/lib/components/sk-chasing-dots/sk-chasing-dots.component.mjs +0 -20
- package/esm2022/lib/components/sk-cube-grid/sk-cube-grid.component.mjs +0 -20
- package/esm2022/lib/components/sk-double-bounce/sk-double-bounce.component.mjs +0 -20
- package/esm2022/lib/components/sk-rotating-plane/sk-rotating-plane.component.mjs +0 -20
- package/esm2022/lib/components/sk-spinner-pulse/sk-spinner-pulse.component.mjs +0 -20
- package/esm2022/lib/components/sk-three-bounce/sk-three-bounce.component.mjs +0 -20
- package/esm2022/lib/components/sk-wandering-cubes/sk-wandering-cubes.component.mjs +0 -20
- package/esm2022/lib/components/sk-wave/sk-wave.component.mjs +0 -20
- package/esm2022/lib/ng-http-loader.module.mjs +0 -52
- package/esm2022/lib/services/pending-requests-interceptor.service.mjs +0 -93
- package/esm2022/lib/services/spinner-visibility.service.mjs +0 -38
- package/esm2022/lib/spinkits.mjs +0 -37
- package/esm2022/ng-http-loader.mjs +0 -5
- package/esm2022/public_api.mjs +0 -18
- package/lib/ng-http-loader.module.d.ts +0 -18
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@ The HTTP interceptor listens to all HTTP requests and shows a spinner / loader i
|
|
|
30
30
|
## Angular Compatibility
|
|
31
31
|
|
|
32
32
|
| ng-http-loader | Angular |
|
|
33
|
-
|
|
33
|
+
|---------------|---------|
|
|
34
34
|
| >=0.1.0 <0.4.0 | ^4.3.0 |
|
|
35
35
|
| >=0.4.0 <1.0.0 | ^5.0.0 |
|
|
36
36
|
| >=1.0.0 <3.2.0 | ^6.0.0 |
|
|
@@ -38,94 +38,60 @@ The HTTP interceptor listens to all HTTP requests and shows a spinner / loader i
|
|
|
38
38
|
| >=6.0.0 <7.0.0 | ^8.0.0 |
|
|
39
39
|
| >=7.0.0 <8.0.0 | ^9.0.0 |
|
|
40
40
|
| >=8.0.0 <9.0.0 | ^10.0.0 |
|
|
41
|
-
| >=9.0.0
|
|
42
|
-
| >=10.0.0
|
|
43
|
-
| >=11.0.0
|
|
44
|
-
| >=12.0.0
|
|
45
|
-
| >=13.0.0
|
|
46
|
-
| >=14.0.0
|
|
47
|
-
| >=15.0.0
|
|
48
|
-
| >=16.0.0
|
|
41
|
+
| >=9.0.0 | ^11.0.0 |
|
|
42
|
+
| >=10.0.0 | ^12.0.0 |
|
|
43
|
+
| >=11.0.0 | ^13.0.0 |
|
|
44
|
+
| >=12.0.0 | ^14.0.0 |
|
|
45
|
+
| >=13.0.0 | ^15.0.0 |
|
|
46
|
+
| >=14.0.0 | ^16.0.0 |
|
|
47
|
+
| >=15.0.0 | ^17.0.0 |
|
|
48
|
+
| >=16.0.0 | ^18.0.0 |
|
|
49
|
+
| >=17.0.0 | ^19.0.0 |
|
|
49
50
|
|
|
50
51
|
If you experience errors like below, **please double-check the version you use.**
|
|
51
52
|
|
|
52
53
|
`ERROR in Error: Metadata version mismatch for module [...]/angular/node_modules/ng-http-loader/ng-http-loader.module.d.ts, found version x, expected y [...]`
|
|
53
54
|
|
|
54
|
-
## Requirements -
|
|
55
|
+
## Requirements - HttpClient
|
|
55
56
|
|
|
56
|
-
Performing HTTP requests with the `
|
|
57
|
-
|
|
58
|
-
See this [blog post](http://blog.ninja-squad.com/2017/07/17/http-client-module/) for an `HttpClientModule` introduction.
|
|
57
|
+
Performing HTTP requests with the `HttpClient` API is **mandatory**. Otherwise, the spinner will not be fired **at all**.
|
|
59
58
|
|
|
60
59
|
## Usage
|
|
61
60
|
|
|
62
|
-
From your Angular `
|
|
61
|
+
From your Angular root component (`app.component.ts` for example):
|
|
63
62
|
|
|
64
63
|
```typescript
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
@NgModule({
|
|
73
|
-
declarations: [
|
|
74
|
-
AppComponent
|
|
75
|
-
],
|
|
76
|
-
imports: [
|
|
77
|
-
BrowserModule,
|
|
78
|
-
HttpClientModule, // <============ (Perform HTTP requests with this module)
|
|
79
|
-
NgHttpLoaderModule.forRoot(), // <============ Don't forget to call 'forRoot()'!
|
|
80
|
-
],
|
|
81
|
-
providers: [],
|
|
82
|
-
bootstrap: [AppComponent]
|
|
64
|
+
@Component({
|
|
65
|
+
selector: 'app-root',
|
|
66
|
+
standalone: true,
|
|
67
|
+
templateUrl: './app.component.html',
|
|
68
|
+
styleUrls: ['./app.component.scss'],
|
|
69
|
+
imports: [NgHttpLoaderComponent] <====== import the component
|
|
83
70
|
})
|
|
84
|
-
export class AppModule { }
|
|
85
71
|
```
|
|
86
72
|
|
|
87
|
-
In your app.component.html
|
|
73
|
+
In your `app.component.html`, simply add:
|
|
88
74
|
```xml
|
|
89
75
|
<ng-http-loader></ng-http-loader>
|
|
90
76
|
```
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
If you prefer using standalone components, you should configure your `ApplicationConfig` like following:
|
|
77
|
+
At last, configure your `ApplicationConfig` like following:
|
|
94
78
|
|
|
95
79
|
```typescript
|
|
96
80
|
import { ApplicationConfig, importProvidersFrom } from '@angular/core';
|
|
97
81
|
import { provideRouter } from '@angular/router';
|
|
98
82
|
import { NgHttpLoaderModule } from 'ng-http-loader';
|
|
99
83
|
import { routes } from './app.routes';
|
|
100
|
-
import {provideHttpClient,
|
|
84
|
+
import { provideHttpClient, withInterceptors } from '@angular/common/http';
|
|
85
|
+
import { pendingRequestsInterceptor$ } from 'ng-http-loader';
|
|
101
86
|
|
|
102
87
|
export const appConfig: ApplicationConfig = {
|
|
103
88
|
providers: [
|
|
104
89
|
provideRouter(routes),
|
|
105
|
-
provideHttpClient(
|
|
106
|
-
withInterceptorsFromDi() // <== Don't forget to import the interceptors
|
|
107
|
-
),
|
|
108
|
-
importProvidersFrom(NgHttpLoaderModule.forRoot()) //<== Always call `forRoot`
|
|
90
|
+
provideHttpClient(withInterceptors([pendingRequestsInterceptor$])),
|
|
109
91
|
],
|
|
110
92
|
};
|
|
111
93
|
```
|
|
112
|
-
Then you can use `ng-http-loader` like this:
|
|
113
|
-
```typescript
|
|
114
|
-
import { Component } from '@angular/core';
|
|
115
|
-
import {NgHttpLoaderModule} from "ng-http-loader";
|
|
116
94
|
|
|
117
|
-
@Component({
|
|
118
|
-
selector: 'my-selector',
|
|
119
|
-
standalone: true,
|
|
120
|
-
imports: [
|
|
121
|
-
NgHttpLoaderModule
|
|
122
|
-
],
|
|
123
|
-
template: `
|
|
124
|
-
<ng-http-loader />`,
|
|
125
|
-
})
|
|
126
|
-
export class InlineComponent {
|
|
127
|
-
}
|
|
128
|
-
```
|
|
129
95
|
## Customizing the spinner
|
|
130
96
|
|
|
131
97
|
You can customize the following parameters:
|
|
@@ -159,8 +125,10 @@ import { Spinkit } from 'ng-http-loader'; // <============
|
|
|
159
125
|
|
|
160
126
|
@Component({
|
|
161
127
|
selector: 'app-root',
|
|
128
|
+
standalone: true,
|
|
162
129
|
templateUrl: './app.component.html',
|
|
163
130
|
styleUrls: ['./app.component.css'],
|
|
131
|
+
imports: [NgHttpLoaderComponent]
|
|
164
132
|
})
|
|
165
133
|
export class AppComponent {
|
|
166
134
|
public spinkit = Spinkit; // <============
|
|
@@ -188,8 +156,10 @@ import { AwesomeComponent } from 'my.awesome.component';
|
|
|
188
156
|
|
|
189
157
|
@Component({
|
|
190
158
|
selector: 'app-root',
|
|
159
|
+
standalone: true,
|
|
191
160
|
templateUrl: './app.component.html',
|
|
192
|
-
styleUrls: ['./app.component.css']
|
|
161
|
+
styleUrls: ['./app.component.css'],
|
|
162
|
+
imports: [NgHttpLoaderComponent]
|
|
193
163
|
})
|
|
194
164
|
export class AppComponent {
|
|
195
165
|
public awesomeComponent = AwesomeComponent;
|