ing
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Store, select } from '@ngrx/store';
|
||||
|
||||
import { Observable, Subject } from 'rxjs';
|
||||
|
||||
import { RPCSubscriber } from '@loafer/ng-rpc';
|
||||
import { LoggerService } from '@loafer/ng-logger';
|
||||
@@ -8,26 +9,47 @@ import { NoAuthProbe } from '@overflow/commons-typescript/model/noauth';
|
||||
|
||||
import * as NoAuthProbeConnectingStore from '../store/connecting';
|
||||
|
||||
export interface NoAuthProbeNotify {
|
||||
method: string;
|
||||
params: NoAuthProbe;
|
||||
}
|
||||
|
||||
export class NoAuthProbeSubscriberSubject extends Subject<NoAuthProbeNotify> {
|
||||
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class NoAuthProbeSubscriber {
|
||||
private noAuthProbeSubscriberSubject: NoAuthProbeSubscriberSubject;
|
||||
|
||||
public constructor(
|
||||
private store: Store<any>,
|
||||
private loggerService: LoggerService,
|
||||
) {
|
||||
this.noAuthProbeSubscriberSubject = null;
|
||||
}
|
||||
|
||||
public observable(): Observable<NoAuthProbeNotify> {
|
||||
if (null === this.noAuthProbeSubscriberSubject) {
|
||||
this.noAuthProbeSubscriberSubject = new NoAuthProbeSubscriberSubject();
|
||||
}
|
||||
return this.noAuthProbeSubscriberSubject.asObservable();
|
||||
}
|
||||
|
||||
private publish(method: string, params: any): void {
|
||||
this.noAuthProbeSubscriberSubject.next({ method: method, params: params });
|
||||
}
|
||||
|
||||
@RPCSubscriber({method: 'NoAuthProbeService.onConnect'})
|
||||
public onConnect(noAuthProbe: NoAuthProbe): void {
|
||||
this.loggerService.debug('NoAuthProbeService.onConnect noAuthProbe:', noAuthProbe);
|
||||
|
||||
this.store.dispatch(new NoAuthProbeConnectingStore.OnConnect(noAuthProbe));
|
||||
this.publish('NoAuthProbeService.onConnect', noAuthProbe);
|
||||
}
|
||||
|
||||
@RPCSubscriber({method: 'NoAuthProbeService.onDisconnect'})
|
||||
public onDisconnect(noAuthProbe: NoAuthProbe): void {
|
||||
this.loggerService.debug('NoAuthProbeService.onDisconnect noAuthProbe:', noAuthProbe);
|
||||
|
||||
this.store.dispatch(new NoAuthProbeConnectingStore.OnDisconnect(noAuthProbe));
|
||||
this.publish('NoAuthProbeService.onDisconnect', noAuthProbe);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user