diff --git a/src/index.ts b/src/index.ts index b520923..415d26c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -27,21 +27,23 @@ const convertV0toV1 = (v0Entry: ExpirableKeyV0): ExpirableKeyV1 => ({ // -- -export interface KeyEvent { - name: string +export interface KeyEvent { + name: Keys } -export interface EventMap { - created: KeyEvent - read: KeyEvent - updated: KeyEvent - deleted: KeyEvent - expired: KeyEvent +export interface EventMap { + created: KeyEvent + read: KeyEvent + updated: KeyEvent + deleted: KeyEvent + expired: KeyEvent } -export type EventTypes = keyof EventMap -export type EventPayload = EventMap[T] -export type Callback = (value: T) => void +export type EventTypes = keyof EventMap +export type EventPayload> = EventMap[T] +export type Callback> = ( + value: EventPayload +) => void export interface ConstructorOptions { name?: string @@ -77,12 +79,12 @@ export default class SessionKeystore { // Event Emitter -- // Returns an unsubscribe callback - on(event: T, callback: Callback) { + on>(event: T, callback: Callback) { this.#emitter.on(event, callback) return () => this.#emitter.off(event, callback) } - off(event: T, callback: Callback) { + off>(event: T, callback: Callback) { this.#emitter.off(event, callback) }