Skip to content

Commit

Permalink
fully type ui/api
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Nov 1, 2024
1 parent 7573f74 commit cb70d43
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
15 changes: 11 additions & 4 deletions ui/@types/lichess/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,21 @@ interface Fipr {
x64hash128(input: string, seed: number): string;
}

interface Events {
on(key: string, cb: (...args: any[]) => void): void;
off(key: string, cb: (...args: any[]) => void): void;
}

interface Api {
initializeDom: (root?: HTMLElement) => void;
events: Events;
socket: {
subscribeToMoveLatency: () => void;
events: Events;
};
onlineFriends: {
request: () => void;
events: {
on(key: string, cb: (...args: any[]) => void): void;
off(key: string, cb: (...args: any[]) => void): void;
};
events: Events;
};
chat: {
post: (text: string) => void;
Expand Down
2 changes: 1 addition & 1 deletion ui/site/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const socketEvents = ['lag', 'close'];
const socketInEvents = ['mlat', 'fen', 'notifications', 'endData'];
const friendsEvents = ['playing', 'stopped_playing', 'onlines', 'enters', 'leaves'];

export const api = (pubsub: Pubsub) => ({
export const api = (pubsub: Pubsub): Api => ({
initializeDom: (root?: HTMLElement) => pubsub.emit('content-loaded', root),
events: {
on(name: PubsubEvent, cb: PubsubCallback): void {
Expand Down

0 comments on commit cb70d43

Please sign in to comment.