Skip to content

Commit

Permalink
Merge pull request IdentityModel#796 from UselessPickles/event-signat…
Browse files Browse the repository at this point in the history
…ure-improvements

Improve typings for UserManagerEvents callback signatures
  • Loading branch information
brockallen authored Aug 7, 2019
2 parents 7abedbc + e914274 commit f493b35
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
28 changes: 18 additions & 10 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,20 +192,28 @@ export interface UserManagerEvents extends AccessTokenEvents {
load(user: User): any;
unload(): any;

addUserLoaded(callback: (...ev: any[]) => void): void;
removeUserLoaded(callback: (...ev: any[]) => void): void;
addUserLoaded(callback: UserManagerEvents.UserLoadedCallback): void;
removeUserLoaded(callback: UserManagerEvents.UserLoadedCallback): void;

addUserUnloaded(callback: (...ev: any[]) => void): void;
removeUserUnloaded(callback: (...ev: any[]) => void): void;
addUserUnloaded(callback: UserManagerEvents.UserUnloadedCallback): void;
removeUserUnloaded(callback: UserManagerEvents.UserUnloadedCallback): void;

addSilentRenewError(callback: (...ev: any[]) => void): void;
removeSilentRenewError(callback: (...ev: any[]) => void): void;
addSilentRenewError(callback: UserManagerEvents.SilentRenewErrorCallback): void;
removeSilentRenewError(callback: UserManagerEvents.SilentRenewErrorCallback): void;

addUserSignedOut(callback: (...ev: any[]) => void): void;
removeUserSignedOut(callback: (...ev: any[]) => void): void;
addUserSignedOut(callback: UserManagerEvents.UserSignedOutCallback): void;
removeUserSignedOut(callback: UserManagerEvents.UserSignedOutCallback): void;

addUserSessionChanged(callback: (...ev: any[]) => void): void;
removeUserSessionChanged(callback: (...ev: any[]) => void): void;
addUserSessionChanged(callback: UserManagerEvents.UserSessionChangedCallback): void;
removeUserSessionChanged(callback: UserManagerEvents.UserSessionChangedCallback): void;
}

export namespace UserManagerEvents {
export type UserLoadedCallback = (user: User) => void;
export type UserUnloadedCallback = () => void;
export type SilentRenewErrorCallback = (error: Error) => void;
export type UserSignedOutCallback = () => void;
export type UserSessionChangedCallback = () => void;
}

export interface UserManagerSettings extends OidcClientSettings {
Expand Down
8 changes: 4 additions & 4 deletions src/UserManagerEvents.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ export class UserManagerEvents extends AccessTokenEvents {
removeUserSignedOut(cb) {
this._userSignedOut.removeHandler(cb);
}
_raiseUserSignedOut(e) {
_raiseUserSignedOut() {
Log.debug("UserManagerEvents._raiseUserSignedOut");
this._userSignedOut.raise(e);
this._userSignedOut.raise();
}

addUserSessionChanged(cb) {
Expand All @@ -71,8 +71,8 @@ export class UserManagerEvents extends AccessTokenEvents {
removeUserSessionChanged(cb) {
this._userSessionChanged.removeHandler(cb);
}
_raiseUserSessionChanged(e) {
_raiseUserSessionChanged() {
Log.debug("UserManagerEvents._raiseUserSessionChanged");
this._userSessionChanged.raise(e);
this._userSessionChanged.raise();
}
}

0 comments on commit f493b35

Please sign in to comment.