Skip to content

Commit fdb7bf5

Browse files
committed
Revert "Revert "Merge pull request #462 from supabase/feat/new-realtime-api""
This reverts commit c9b4f89.
1 parent 03259e0 commit fdb7bf5

File tree

12 files changed

+292
-496
lines changed

12 files changed

+292
-496
lines changed

example/next-storage/components/ProfileList.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
import ProfileCard from '../components/ProfileCard'
22
import { Profile } from '../lib/constants'
3-
import { Subscription, SupabaseRealtimePayload } from '@supabase/supabase-js'
43
import { supabase } from '../lib/api'
54
import { useState, useEffect } from 'react'
65

7-
var realtimeProfiles: Subscription | null = null
8-
96
export default function ProfileList() {
107
const [profiles, setProfiles] = useState<Profile[]>([])
118

129
useEffect(() => {
1310
// getPublicProfiles()
1411
getUserProfile()
1512

16-
realtimeProfiles = supabase
17-
.from('profiles')
18-
.on('*', (payload: SupabaseRealtimePayload<Profile>) => profileUpdated(profiles, payload.new))
13+
const realtimeProfiles = supabase
14+
.channel('profiles-channel')
15+
.on(
16+
'postgres_changes',
17+
{ event: '*', schema: 'public', table: 'profiles' },
18+
(payload: { [key: string]: any }) => profileUpdated(profiles, payload.new)
19+
)
1920
.subscribe()
2021

2122
return () => {
22-
if (realtimeProfiles) supabase.removeSubscription(realtimeProfiles)
23+
if (realtimeProfiles) supabase.removeChannel(realtimeProfiles)
2324
}
2425
}, [])
2526

0 commit comments

Comments
 (0)