Skip to content
This repository has been archived by the owner on Jan 10, 2024. It is now read-only.

Commit

Permalink
feat: return destructor functions from event listener methods
Browse files Browse the repository at this point in the history
  • Loading branch information
kherock committed Dec 15, 2021
1 parent ecc91f9 commit 6fa9632
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 27 deletions.
16 changes: 8 additions & 8 deletions docs/oidc-client-ts.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export class AccessTokenEvents {
constructor({ expiringNotificationTimeInSeconds }: {
expiringNotificationTimeInSeconds: number;
});
addAccessTokenExpired(cb: AccessTokenCallback): void;
addAccessTokenExpiring(cb: AccessTokenCallback): void;
addAccessTokenExpired(cb: AccessTokenCallback): () => void;
addAccessTokenExpiring(cb: AccessTokenCallback): () => void;
// (undocumented)
load(container: User): void;
// Warning: (ae-forgotten-export) The symbol "Logger" needs to be exported by the entry point index.d.ts
Expand Down Expand Up @@ -823,12 +823,12 @@ export class UserManager {
// @public (undocumented)
export class UserManagerEvents extends AccessTokenEvents {
constructor(settings: UserManagerSettingsStore);
addSilentRenewError(cb: SilentRenewErrorCallback): void;
addUserLoaded(cb: UserLoadedCallback): void;
addUserSessionChanged(cb: UserSessionChangedCallback): void;
addUserSignedIn(cb: UserSignedInCallback): void;
addUserSignedOut(cb: UserSignedOutCallback): void;
addUserUnloaded(cb: UserUnloadedCallback): void;
addSilentRenewError(cb: SilentRenewErrorCallback): () => void;
addUserLoaded(cb: UserLoadedCallback): () => void;
addUserSessionChanged(cb: UserSessionChangedCallback): () => void;
addUserSignedIn(cb: UserSignedInCallback): () => void;
addUserSignedOut(cb: UserSignedOutCallback): () => void;
addUserUnloaded(cb: UserUnloadedCallback): () => void;
// (undocumented)
load(user: User, raiseEvent?: boolean): void;
// @internal (undocumented)
Expand Down
8 changes: 4 additions & 4 deletions src/AccessTokenEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ export class AccessTokenEvents {
/**
* Add callback: Raised prior to the access token expiring.
*/
public addAccessTokenExpiring(cb: AccessTokenCallback): void {
this._expiringTimer.addHandler(cb);
public addAccessTokenExpiring(cb: AccessTokenCallback): () => void {
return this._expiringTimer.addHandler(cb);
}
/**
* Remove callback: Raised prior to the access token expiring.
Expand All @@ -81,8 +81,8 @@ export class AccessTokenEvents {
/**
* Add callback: Raised after the access token has expired.
*/
public addAccessTokenExpired(cb: AccessTokenCallback): void {
this._expiredTimer.addHandler(cb);
public addAccessTokenExpired(cb: AccessTokenCallback): () => void {
return this._expiredTimer.addHandler(cb);
}
/**
* Remove callback: Raised after the access token has expired.
Expand Down
30 changes: 15 additions & 15 deletions src/UserManagerEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,40 +70,40 @@ export class UserManagerEvents extends AccessTokenEvents {
/**
* Add callback: Raised when a user session has been established (or re-established).
*/
public addUserLoaded(cb: UserLoadedCallback): void {
this._userLoaded.addHandler(cb);
public addUserLoaded(cb: UserLoadedCallback): () => void {
return this._userLoaded.addHandler(cb);
}
/**
* Remove callback: Raised when a user session has been established (or re-established).
*/
public removeUserLoaded(cb: UserLoadedCallback): void {
this._userLoaded.removeHandler(cb);
return this._userLoaded.removeHandler(cb);
}

/**
* Add callback: Raised when a user session has been terminated.
*/
public addUserUnloaded(cb: UserUnloadedCallback): void {
this._userUnloaded.addHandler(cb);
public addUserUnloaded(cb: UserUnloadedCallback): () => void {
return this._userUnloaded.addHandler(cb);
}
/**
* Remove callback: Raised when a user session has been terminated.
*/
public removeUserUnloaded(cb: UserUnloadedCallback): void {
this._userUnloaded.removeHandler(cb);
return this._userUnloaded.removeHandler(cb);
}

/**
* Add callback: Raised when the automatic silent renew has failed.
*/
public addSilentRenewError(cb: SilentRenewErrorCallback): void {
this._silentRenewError.addHandler(cb);
public addSilentRenewError(cb: SilentRenewErrorCallback): () => void {
return this._silentRenewError.addHandler(cb);
}
/**
* Remove callback: Raised when the automatic silent renew has failed.
*/
public removeSilentRenewError(cb: SilentRenewErrorCallback): void {
this._silentRenewError.removeHandler(cb);
return this._silentRenewError.removeHandler(cb);
}
/**
* @internal
Expand All @@ -116,8 +116,8 @@ export class UserManagerEvents extends AccessTokenEvents {
/**
* Add callback: Raised when the user is signed in.
*/
public addUserSignedIn(cb: UserSignedInCallback): void {
this._userSignedIn.addHandler(cb);
public addUserSignedIn(cb: UserSignedInCallback): () => void {
return this._userSignedIn.addHandler(cb);
}
/**
* Remove callback: Raised when the user is signed in.
Expand All @@ -136,8 +136,8 @@ export class UserManagerEvents extends AccessTokenEvents {
/**
* Add callback: Raised when the user's sign-in status at the OP has changed.
*/
public addUserSignedOut(cb: UserSignedOutCallback): void {
this._userSignedOut.addHandler(cb);
public addUserSignedOut(cb: UserSignedOutCallback): () => void {
return this._userSignedOut.addHandler(cb);
}
/**
* Remove callback: Raised when the user's sign-in status at the OP has changed.
Expand All @@ -156,8 +156,8 @@ export class UserManagerEvents extends AccessTokenEvents {
/**
* Add callback: Raised when the user session changed (when `monitorSession` is set)
*/
public addUserSessionChanged(cb: UserSessionChangedCallback): void {
this._userSessionChanged.addHandler(cb);
public addUserSessionChanged(cb: UserSessionChangedCallback): () => void {
return this._userSessionChanged.addHandler(cb);
}
/**
* Remove callback: Raised when the user session changed (when `monitorSession` is set)
Expand Down

0 comments on commit 6fa9632

Please sign in to comment.