File tree 2 files changed +25
-1
lines changed
2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change
1
+ import { Injectable } from '@angular/core' ;
2
+ import { Actions , createEffect } from '@ngrx/effects' ;
3
+
4
+
5
+ @Injectable ( )
6
+ export class AuthEffects {
7
+
8
+ constructor ( private actions$ : Actions ) {
9
+
10
+ actions$ . subscribe ( action => {
11
+
12
+ if ( action . type == '[Login Page] User Login' ) {
13
+
14
+ localStorage . setItem ( 'user' ,
15
+ JSON . stringify ( action [ "user" ] ) ) ;
16
+ }
17
+
18
+
19
+ } ) ;
20
+
21
+ }
22
+
23
+ }
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import * as fromAuth from './reducers';
12
12
import { authReducer } from './reducers' ;
13
13
import { AuthGuard } from './auth.guard' ;
14
14
import { EffectsModule } from '@ngrx/effects' ;
15
+ import { AuthEffects } from './auth.effects' ;
15
16
16
17
@NgModule ( {
17
18
imports : [
@@ -22,7 +23,7 @@ import {EffectsModule} from '@ngrx/effects';
22
23
MatButtonModule ,
23
24
RouterModule . forChild ( [ { path : '' , component : LoginComponent } ] ) ,
24
25
StoreModule . forFeature ( 'auth' , authReducer ) ,
25
- EffectsModule . forFeature ( [ ] )
26
+ EffectsModule . forFeature ( [ AuthEffects ] )
26
27
] ,
27
28
declarations : [ LoginComponent ] ,
28
29
exports : [ LoginComponent ]
You can’t perform that action at this time.
0 commit comments