Skip to content

Commit

Permalink
Revert "Merge pull request #462 from supabase/feat/new-realtime-api"
Browse files Browse the repository at this point in the history
This reverts commit bd03b65, reversing
changes made to f37643c.
  • Loading branch information
w3b6x9 committed Aug 16, 2022
1 parent f5759a7 commit c9b4f89
Show file tree
Hide file tree
Showing 12 changed files with 496 additions and 292 deletions.
15 changes: 7 additions & 8 deletions example/next-storage/components/ProfileList.tsx
@@ -1,26 +1,25 @@
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()

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

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

Expand Down

0 comments on commit c9b4f89

Please sign in to comment.