ing
This commit is contained in:
5
src/app/commons/store/index.ts
Normal file
5
src/app/commons/store/index.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import * as SigninInitStore from './signin-init';
|
||||
|
||||
export const EFFECTS = [
|
||||
SigninInitStore.Effects,
|
||||
];
|
||||
1
src/app/commons/store/signin-init/index.ts
Normal file
1
src/app/commons/store/signin-init/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from './signin-init.effect';
|
||||
15
src/app/commons/store/signin-init/signin-init.effect.spec.ts
Normal file
15
src/app/commons/store/signin-init/signin-init.effect.spec.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { TestBed, inject } from '@angular/core/testing';
|
||||
|
||||
import { Effects } from './signin-init.effect';
|
||||
|
||||
describe('SigninInit.Effects', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [Effects]
|
||||
});
|
||||
});
|
||||
|
||||
it('should be created', inject([Effects], (effects: Effects) => {
|
||||
expect(effects).toBeTruthy();
|
||||
}));
|
||||
});
|
||||
43
src/app/commons/store/signin-init/signin-init.effect.ts
Normal file
43
src/app/commons/store/signin-init/signin-init.effect.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
import { Effect, Actions, ofType } from '@ngrx/effects';
|
||||
import { Action } from '@ngrx/store';
|
||||
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { of } from 'rxjs/observable/of';
|
||||
|
||||
import 'rxjs/add/operator/catch';
|
||||
import 'rxjs/add/operator/do';
|
||||
import 'rxjs/add/operator/exhaustMap';
|
||||
import 'rxjs/add/operator/switchMap';
|
||||
import 'rxjs/add/operator/map';
|
||||
import 'rxjs/add/operator/take';
|
||||
|
||||
import { RPCClient } from 'packages/core/rpc/client/RPCClient';
|
||||
|
||||
import {
|
||||
Signin,
|
||||
SigninSuccess,
|
||||
SigninFailure,
|
||||
ActionType,
|
||||
} from 'packages/member/store/auth';
|
||||
|
||||
@Injectable()
|
||||
export class Effects {
|
||||
|
||||
constructor(
|
||||
private actions$: Actions,
|
||||
private rpcClient: RPCClient,
|
||||
) { }
|
||||
|
||||
@Effect({ dispatch: false })
|
||||
signinSuccess$ = this.actions$
|
||||
.ofType(ActionType.SigninSuccess)
|
||||
.do(
|
||||
() => {
|
||||
this.rpcClient.connect();
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user