question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Just trying to use basic realtime features within a Vue component like so:

<script lang="ts" setup>
import type { WorkEvent } from '~/types/event';
const supabase = useSupabaseClient();
const props = defineProps<{ event: WorkEvent; }>();

const { data: count } = await useAsyncData('votes-count', async () => {
  const { count } = await supabase.from('user-votes').select('*', { count: 'exact' }).eq('event', props.event.id);
  return count;
});

supabase.from('user-votes').on('*', () => {
    refreshNuxtData('votes-count');
}).subscribe();

</script>

<template>
  <NuxtLink
    :to="`/dashboard/events/${props.event.id}`"
  >
    <div class="card card-compact w-full bg-base-100">
      <div class="card-body">
        <h2 class="card-title line-clamp-1">
          {{ props.event.name }}
        </h2>
        <p class="line-clamp-3">
          {{ props.event.description }}
        </p>
        <div class="card-actions">
          <div class="badge">
            {{ count }} votes
          </div>
        </div>
      </div>
    </div>
  </NuxtLink>
</template>

But this does not work and throws a Cannot read properties of undefined (reading 'event') error the moment I try to use the subscribe feature.

Is there a way to get those feature working or is this out of the scope of this module for now?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
amrnn90commented, Jun 1, 2022

Try wrapping the subscription inside an onMounted hook:

let subscription;

onMounted(() => {
  subscription = supabase.from('user-votes').on('*', () => {
      refreshNuxtData('votes-count');
  }).subscribe();
})

Also make sure to unsubscribe on unmount:

onUnmounted(() => {
  supabase.removeSubscription(subscription);
});

And make sure you have turned on the Real Time API for your table.

0reactions
larbishcommented, Jun 10, 2022

Indeed ! Thanks !

Read more comments on GitHub >

github_iconTop Results From Across the Web

Real-Time Feature Engineering with a Feature store
So let's talk about the difference between real-time and batch feature stores… Batch: Slow, suitable for training processes that can take hours.
Read more >
Near real-time features for near real-time personalization
The near-real time features can capture the short-term intent and preferences of a member, while the other features can capture the ...
Read more >
Feature Stores for Real-time AI & Machine Learning
The feature store is used for real-time use cases as Recommendations, Churn & Premium Predictions, Ranking and Spam Classifier, and is ...
Read more >
Building Real-Time ML Pipelines with a Feature Store - Medium
First, let's review the difference between real-time and batch feature stores… Batch: Slow, suitable for training processes that can take hours.
Read more >
Building Riviera: A Declarative Real-Time Feature ...
Real-time features enable DoorDash's models to be more predictive, the challenge is making them easier to configure.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found