Skip to content

Commit

Permalink
convert *EventMap types to interfaces
Browse files Browse the repository at this point in the history
this allows me to link to the documentation of each of their properties

I don’t really understand why `extends EventMap` fixes the compiler
error I get without this, nor whether it’s the best solution.
  • Loading branch information
lawrence-forooghian committed Sep 21, 2023
1 parent a5f920e commit 6ae4ec4
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
5 changes: 3 additions & 2 deletions src/Cursors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import EventEmitter, {
inspect,
type EventKey,
type EventListener,
type EventMap,
} from './utilities/EventEmitter.js';
import CursorHistory from './CursorHistory.js';
import { CURSOR_UPDATE } from './CursorConstants.js';
Expand All @@ -16,9 +17,9 @@ import type { CursorsOptions, CursorUpdate } from './types.js';
import type { RealtimeMessage } from './utilities/types.js';
import { ERR_NOT_ENTERED_SPACE } from './Errors.js';

export type CursorsEventMap = {
export interface CursorsEventMap extends EventMap {
update: CursorUpdate;
};
}

const CURSORS_CHANNEL_TAG = '::$cursors';

Expand Down
5 changes: 3 additions & 2 deletions src/Locations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import EventEmitter, {
inspect,
type EventKey,
type EventListener,
type EventMap,
} from './utilities/EventEmitter.js';

import type { SpaceMember } from './types.js';
Expand All @@ -20,9 +21,9 @@ export namespace LocationsEvents {
}
}

export type LocationsEventMap = {
export interface LocationsEventMap extends EventMap {
update: LocationsEvents.UpdateEvent;
};
}

/**
* <!-- BEGIN WEBSITE DOCUMENTATION (https://github.com/ably/docs/blob/14acea6dee7bf3872a3d32d43732f934cbe93a7d/content/spaces/locations.textile?plain=1#L9-L11) -->
Expand Down
5 changes: 3 additions & 2 deletions src/Locks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import EventEmitter, {
inspect,
type EventKey,
type EventListener,
type EventMap,
} from './utilities/EventEmitter.js';

/**
Expand All @@ -30,9 +31,9 @@ export interface LockOptions {
attributes: LockAttributes;
}

export type LocksEventMap = {
export interface LocksEventMap extends EventMap {
update: Lock;
};
}

/**
* <!-- BEGIN WEBSITE DOCUMENTATION (https://github.com/ably/docs/blob/14acea6dee7bf3872a3d32d43732f934cbe93a7d/content/spaces/locking.textile?plain=1#L9-L37) -->
Expand Down
5 changes: 3 additions & 2 deletions src/Members.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,21 @@ import EventEmitter, {
inspect,
type EventKey,
type EventListener,
type EventMap,
} from './utilities/EventEmitter.js';
import Leavers from './Leavers.js';

import type { SpaceMember } from './types.js';
import type { PresenceMember } from './utilities/types.js';
import type Space from './Space.js';

export type MembersEventMap = {
export interface MembersEventMap extends EventMap {
leave: SpaceMember;
enter: SpaceMember;
update: SpaceMember;
updateProfile: SpaceMember;
remove: SpaceMember;
};
}

/**
* <!-- BEGIN WEBSITE DOCUMENTATION (https://github.com/ably/docs/blob/14acea6dee7bf3872a3d32d43732f934cbe93a7d/content/spaces/avatar.textile?plain=1#L9-L24) -->
Expand Down
5 changes: 3 additions & 2 deletions src/Space.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import EventEmitter, {
inspect,
type EventKey,
type EventListener,
type EventMap,
} from './utilities/EventEmitter.js';
import Locations from './Locations.js';
import Cursors from './Cursors.js';
Expand Down Expand Up @@ -36,9 +37,9 @@ export namespace SpaceEvents {
}
}

export type SpaceEventMap = {
export interface SpaceEventMap extends EventMap {
update: SpaceEvents.UpdateEvent;
};
}

/**
* <!-- BEGIN WEBSITE DOCUMENTATION (https://github.com/ably/docs/blob/14acea6dee7bf3872a3d32d43732f934cbe93a7d/content/spaces/space.textile?plain=1#L9-L22) -->
Expand Down

0 comments on commit 6ae4ec4

Please sign in to comment.