File tree 6 files changed +8
-63
lines changed
6 files changed +8
-63
lines changed Original file line number Diff line number Diff line change 1
1
import * as MessageApiActions from './message.actions' ;
2
- import * as SpinnerActions from './spinner.actions' ;
3
2
import * as UserActions from './user.actions' ;
4
3
5
- export { MessageApiActions , SpinnerActions , UserActions } ;
4
+ export { MessageApiActions , UserActions } ;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 5
5
HttpRequest ,
6
6
} from '@angular/common/http' ;
7
7
import { Injectable } from '@angular/core' ;
8
- import { IsLoadingService } from '@service-work/is-loading' ;
9
8
import { Observable } from 'rxjs' ;
10
9
import { finalize } from 'rxjs/operators' ;
11
10
import { SpinnerFacadeService } from '../services/spinner-facade.service' ;
@@ -14,18 +13,14 @@ import { SpinnerFacadeService } from '../services/spinner-facade.service';
14
13
export class LoadingInterceptor implements HttpInterceptor {
15
14
activeRequests = 0 ;
16
15
17
- constructor (
18
- private loadingService : IsLoadingService ,
19
- private spinnerFacade : SpinnerFacadeService
20
- ) { }
16
+ constructor ( private spinnerFacade : SpinnerFacadeService ) { }
21
17
22
18
intercept (
23
19
request : HttpRequest < any > ,
24
20
next : HttpHandler
25
21
) : Observable < HttpEvent < any > > {
26
22
if ( this . activeRequests === 0 ) {
27
23
this . spinnerFacade . show ( ) ;
28
- this . loadingService . add ( { key : 'loading' } ) ;
29
24
}
30
25
31
26
this . activeRequests ++ ;
@@ -36,7 +31,6 @@ export class LoadingInterceptor implements HttpInterceptor {
36
31
37
32
if ( this . activeRequests === 0 ) {
38
33
this . spinnerFacade . hide ( ) ;
39
- this . loadingService . remove ( { key : 'loading' } ) ;
40
34
}
41
35
} )
42
36
) ;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
1
import { Injectable } from '@angular/core' ;
2
- import { select , Store } from '@ngrx/store ' ;
2
+ import { IsLoadingService } from '@service-work/is-loading ' ;
3
3
import { Observable } from 'rxjs' ;
4
- import * as fromRoot from '../../reducers' ;
5
- import { SpinnerActions } from '../actions' ;
6
4
7
5
@Injectable ( )
8
6
export class SpinnerFacadeService {
7
+ private key = 'loading' ;
9
8
showSpinner$ : Observable < boolean > ;
10
9
11
- constructor ( private store : Store < fromRoot . State > ) {
12
- this . showSpinner$ = this . store . pipe ( select ( fromRoot . selectShowSpinner ) ) ;
10
+ constructor ( private isLoadingService : IsLoadingService ) {
11
+ this . showSpinner$ = this . isLoadingService . isLoading$ ( { key : this . key } ) ;
13
12
}
14
13
15
14
hide ( ) : void {
16
- this . store . dispatch ( SpinnerActions . hideSpinner ( ) ) ;
15
+ this . isLoadingService . remove ( { key : this . key } ) ;
17
16
}
18
17
19
18
show ( ) : void {
20
- this . store . dispatch ( SpinnerActions . showSpinner ( ) ) ;
19
+ this . isLoadingService . add ( { key : this . key } ) ;
21
20
}
22
21
}
Original file line number Diff line number Diff line change @@ -4,24 +4,19 @@ import {
4
4
Action ,
5
5
ActionReducer ,
6
6
ActionReducerMap ,
7
- createFeatureSelector ,
8
- createSelector ,
9
7
MetaReducer ,
10
8
} from '@ngrx/store' ;
11
9
import { environment } from '../../environments/environment' ;
12
10
import { AuthActions } from '../auth/actions' ;
13
- import * as fromSpinner from '../core/reducers/spinner.reducers' ;
14
11
15
12
export interface State {
16
- [ fromSpinner . spinnerFeatureKey ] : fromSpinner . State ;
17
13
router : fromRouter . RouterReducerState < any > ;
18
14
}
19
15
20
16
export const ROOT_REDUCERS = new InjectionToken <
21
17
ActionReducerMap < State , Action >
22
18
> ( 'Root reducers token' , {
23
19
factory : ( ) => ( {
24
- [ fromSpinner . spinnerFeatureKey ] : fromSpinner . reducer ,
25
20
router : fromRouter . routerReducer ,
26
21
} ) ,
27
22
} ) ;
@@ -56,16 +51,3 @@ export function clearState(
56
51
export const metaReducers : MetaReducer < State > [ ] = ! environment . production
57
52
? [ clearState , logger ]
58
53
: [ clearState ] ;
59
-
60
- /**
61
- * Spinner Reducers
62
- */
63
- export const selectSpinnerState = createFeatureSelector <
64
- State ,
65
- fromSpinner . State
66
- > ( fromSpinner . spinnerFeatureKey ) ;
67
-
68
- export const selectShowSpinner = createSelector (
69
- selectSpinnerState ,
70
- fromSpinner . getShowSpinner
71
- ) ;
You can’t perform that action at this time.
0 commit comments