mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
AAE-30878 Migrating from event-emitter to eventemitter3 (#11187)
* AAE-30878 Migrating from event-emitter to eventemitter3 which is … (#11116) * [AAE-30878] - have a single place for the EventEmitter types
This commit is contained in:
@@ -16,18 +16,20 @@
|
||||
*/
|
||||
|
||||
import { HttpHeaders } from '@angular/common/http';
|
||||
import ee from 'event-emitter';
|
||||
import { EventEmitter } from 'eventemitter3';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
type EventEmitterInstance = InstanceType<typeof EventEmitter>;
|
||||
|
||||
export interface AuthenticationServiceInterface {
|
||||
onError: any;
|
||||
onLogin: any;
|
||||
onLogout: any;
|
||||
|
||||
on: ee.EmitterMethod;
|
||||
off: ee.EmitterMethod;
|
||||
once: ee.EmitterMethod;
|
||||
emit: (type: string, ...args: any[]) => void;
|
||||
on: EventEmitterInstance['on'];
|
||||
off: EventEmitterInstance['off'];
|
||||
once: EventEmitterInstance['once'];
|
||||
emit: EventEmitterInstance['emit'];
|
||||
|
||||
getToken(): string;
|
||||
isLoggedIn(): boolean;
|
||||
|
||||
@@ -21,13 +21,13 @@ import { BasicAlfrescoAuthService } from '../basic-auth/basic-alfresco-auth.serv
|
||||
import { Observable, Subject, from } from 'rxjs';
|
||||
import { HttpHeaders } from '@angular/common/http';
|
||||
import { AuthenticationServiceInterface } from '../interfaces/authentication-service.interface';
|
||||
import ee from 'event-emitter';
|
||||
import { RedirectAuthService } from '../oidc/redirect-auth.service';
|
||||
|
||||
import { EventEmitter } from 'eventemitter3';
|
||||
type EventEmitterInstance = InstanceType<typeof EventEmitter>;
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class AuthenticationService implements AuthenticationServiceInterface, ee.Emitter {
|
||||
export class AuthenticationService implements AuthenticationServiceInterface {
|
||||
onLogin: Subject<any> = new Subject<any>();
|
||||
onLogout: Subject<any> = new Subject<any>();
|
||||
onTokenReceived: Subject<any> = new Subject<any>();
|
||||
@@ -49,19 +49,19 @@ export class AuthenticationService implements AuthenticationServiceInterface, ee
|
||||
}
|
||||
}
|
||||
|
||||
get on(): ee.EmitterMethod {
|
||||
get on(): EventEmitterInstance['on'] {
|
||||
return this.isOauth() ? this.oidcAuthenticationService.on : this.basicAlfrescoAuthService.on;
|
||||
}
|
||||
|
||||
get off(): ee.EmitterMethod {
|
||||
get off(): EventEmitterInstance['off'] {
|
||||
return this.isOauth() ? this.oidcAuthenticationService.off : this.basicAlfrescoAuthService.off;
|
||||
}
|
||||
|
||||
get once(): ee.EmitterMethod {
|
||||
get once(): EventEmitterInstance['once'] {
|
||||
return this.isOauth() ? this.oidcAuthenticationService.once : this.basicAlfrescoAuthService.once;
|
||||
}
|
||||
|
||||
get emit(): (type: string, ...args: any[]) => void {
|
||||
get emit(): EventEmitterInstance['emit'] {
|
||||
return this.isOauth() ? this.oidcAuthenticationService.emit : this.basicAlfrescoAuthService.emit;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,13 +21,12 @@ import { Observable, Observer, ReplaySubject, throwError } from 'rxjs';
|
||||
import { AppConfigService, AppConfigValues } from '../../app-config/app-config.service';
|
||||
import { CookieService } from '../../common/services/cookie.service';
|
||||
import { AuthenticationServiceInterface } from '../interfaces/authentication-service.interface';
|
||||
import ee from 'event-emitter';
|
||||
|
||||
export abstract class BaseAuthenticationService implements AuthenticationServiceInterface, ee.Emitter {
|
||||
on: ee.EmitterMethod;
|
||||
off: ee.EmitterMethod;
|
||||
once: ee.EmitterMethod;
|
||||
emit: (type: string, ...args: any[]) => void;
|
||||
import { EventEmitterInstance } from '@alfresco/js-api';
|
||||
export abstract class BaseAuthenticationService implements AuthenticationServiceInterface {
|
||||
on: EventEmitterInstance['on'];
|
||||
off: EventEmitterInstance['off'];
|
||||
once: EventEmitterInstance['once'];
|
||||
emit: EventEmitterInstance['emit'];
|
||||
|
||||
protected redirectUrl: RedirectionModel = null;
|
||||
|
||||
@@ -38,9 +37,7 @@ export abstract class BaseAuthenticationService implements AuthenticationService
|
||||
protected constructor(
|
||||
protected appConfig: AppConfigService,
|
||||
protected cookie: CookieService
|
||||
) {
|
||||
ee(this);
|
||||
}
|
||||
) {}
|
||||
|
||||
abstract getAuthHeaders(requestUrl: string, header: HttpHeaders): HttpHeaders;
|
||||
abstract getToken(): string;
|
||||
|
||||
Reference in New Issue
Block a user