File tree Expand file tree Collapse file tree 3 files changed +6
-4
lines changed Expand file tree Collapse file tree 3 files changed +6
-4
lines changed Original file line number Diff line number Diff line change 1
1
import { PostgrestQueryBuilder } from '@supabase/postgrest-js'
2
2
import { SupabaseRealtimeClient } from './SupabaseRealtimeClient'
3
3
import { RealtimeClient } from '@supabase/realtime-js'
4
- import { SupabaseRealtimePayload } from './types'
4
+ import { SupabaseEventTypes , SupabaseRealtimePayload } from './types'
5
5
6
6
export class SupabaseQueryBuilder < T > extends PostgrestQueryBuilder < T > {
7
7
private _subscription : SupabaseRealtimeClient
@@ -33,7 +33,7 @@ export class SupabaseQueryBuilder<T> extends PostgrestQueryBuilder<T> {
33
33
* @param callback A callback that will handle the payload that is sent whenever your database changes.
34
34
*/
35
35
on (
36
- event : 'INSERT' | 'UPDATE' | 'DELETE' | '*' ,
36
+ event : SupabaseEventTypes ,
37
37
callback : ( payload : SupabaseRealtimePayload < T > ) => void
38
38
) : SupabaseRealtimeClient {
39
39
if ( ! this . _realtime . isConnected ( ) ) {
Original file line number Diff line number Diff line change 1
1
import { RealtimeSubscription , RealtimeClient , Transformers } from '@supabase/realtime-js'
2
- import { SupabaseRealtimePayload } from './types'
2
+ import { SupabaseEventTypes , SupabaseRealtimePayload } from './types'
3
3
4
4
export class SupabaseRealtimeClient {
5
5
subscription : RealtimeSubscription
@@ -39,7 +39,7 @@ export class SupabaseRealtimeClient {
39
39
* @param event The event
40
40
* @param callback A callback function that is called whenever the event occurs.
41
41
*/
42
- on ( event : 'INSERT' | 'UPDATE' | 'DELETE' | '*' , callback : Function ) {
42
+ on ( event : SupabaseEventTypes , callback : Function ) {
43
43
this . subscription . on ( event , ( payload : any ) => {
44
44
let enrichedPayload : SupabaseRealtimePayload < any > = {
45
45
schema : payload . schema ,
Original file line number Diff line number Diff line change @@ -35,3 +35,5 @@ export type SupabaseRealtimePayload<T> = {
35
35
/** The previous record. Present for 'UPDATE' and 'DELETE' events. */
36
36
old : T
37
37
}
38
+
39
+ export type SupabaseEventTypes = 'INSERT' | 'UPDATE' | 'DELETE' | '*'
You can’t perform that action at this time.
0 commit comments