Skip to content

Action on realtime disconnect or after a set period of time. #730

Answered by kiwicopple
vin-ce asked this question in Questions
Discussion options

You must be logged in to vote

👋 just trying to guess the intent of you question: Are you trying to determine when somebody is "online" (for things like chat apps)?

If so, this is called "Presence". It's something we will offer in the future, but haven't built yet

To answer your question more specifically - this should be possible to do like this:

    const mySubscription = supabase
    .from('*')
    .on('*', (payload) => {
      console.log('Change received!', payload)
    })
    .subscribe()

    mySubscription.onClose(() => {
      // Do something
    })

The reason why this isn't a great idea for "Presence" use-cases is because there could be a failure to "delete the row on disconnect". Ideally you want the server …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@vin-ce
Comment options

Answer selected by vin-ce
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants