Skip to content

Commit

Permalink
Revert "Revert "Merge pull request #462 from supabase/feat/new-realti…
Browse files Browse the repository at this point in the history
…me-api""

This reverts commit c9b4f89.
  • Loading branch information
w3b6x9 committed Aug 16, 2022
1 parent 03259e0 commit fdb7bf5
Show file tree
Hide file tree
Showing 12 changed files with 292 additions and 496 deletions.
15 changes: 8 additions & 7 deletions example/next-storage/components/ProfileList.tsx
@@ -1,25 +1,26 @@
import ProfileCard from '../components/ProfileCard'
import { Profile } from '../lib/constants'
import { Subscription, SupabaseRealtimePayload } from '@supabase/supabase-js'
import { supabase } from '../lib/api'
import { useState, useEffect } from 'react'

var realtimeProfiles: Subscription | null = null

export default function ProfileList() {
const [profiles, setProfiles] = useState<Profile[]>([])

useEffect(() => {
// getPublicProfiles()
getUserProfile()

realtimeProfiles = supabase
.from('profiles')
.on('*', (payload: SupabaseRealtimePayload<Profile>) => profileUpdated(profiles, payload.new))
const realtimeProfiles = supabase
.channel('profiles-channel')
.on(
'postgres_changes',
{ event: '*', schema: 'public', table: 'profiles' },
(payload: { [key: string]: any }) => profileUpdated(profiles, payload.new)
)
.subscribe()

return () => {
if (realtimeProfiles) supabase.removeSubscription(realtimeProfiles)
if (realtimeProfiles) supabase.removeChannel(realtimeProfiles)
}
}, [])

Expand Down

0 comments on commit fdb7bf5

Please sign in to comment.