Skip to content

Commit

Permalink
fix: Add type to system messages (#422)
Browse files Browse the repository at this point in the history
To help users debug issues and avoid type errors we're adding system as a type of message users can add `on` callbacks
  • Loading branch information
filipecabaco authored Sep 4, 2024
1 parent 95ab09e commit c1b27e1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
9 changes: 6 additions & 3 deletions src/RealtimeChannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,8 @@ export enum REALTIME_POSTGRES_CHANGES_LISTEN_EVENT {
export enum REALTIME_LISTEN_TYPES {
BROADCAST = 'broadcast',
PRESENCE = 'presence',
/**
* listen to Postgres changes.
*/
POSTGRES_CHANGES = 'postgres_changes',
SYSTEM = 'system',
}

export enum REALTIME_SUBSCRIBE_STATES {
Expand Down Expand Up @@ -415,6 +413,11 @@ export default class RealtimeChannel {
payload: T
}) => void
): RealtimeChannel
on<T extends { [key: string]: any }>(
type: `${REALTIME_LISTEN_TYPES.SYSTEM}`,
filter: {},
callback: (payload: any) => void
): RealtimeChannel
on(
type: `${REALTIME_LISTEN_TYPES}`,
filter: { event: string; [key: string]: string },
Expand Down
3 changes: 1 addition & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"esModuleInterop": true,
"moduleResolution": "Node",
"forceConsistentCasingInFileNames": true,
"stripInternal": true,
"types": ["vitest/globals"]
"stripInternal": true
}
}

0 comments on commit c1b27e1

Please sign in to comment.