Back

React Native Expo Realtime not working

  • 0
  • Databases
  • Cloud
testadicazzo77
5 May, 2024, 10:54

hi , so currently trying to move from pocketbase to appwrite and kinda stuck.. I wanna implement realtime for all collections so users get updated records all the time.. im using treact native sdk and I can fetch collection but realtime doesn't work as I keep getting

Realtime got disconnected. Reconnect will be attempted in 1 seconds. Stream end encountered am I doing something wrong ?

import {Client, Databases} from 'react-native-appwrite';

const fetchEvents = async () => { try { let result = await databases.listDocuments(databaseId, collectionId); let documents = result.documents;

TypeScript
    setEvents(documents);

    console.log('Documents:', events);

    client.subscribe(`collections.${collectionId}.documents`, (response) => {
        let updatedDocuments = response.payload;

        setEvents(updatedDocuments);

        console.log('Updated Documents:', updatedDocuments);
    });

} catch (error) {
    console.error(error);
}

};

TL;DR
Developers wants to implement realtime updates using React Native Expo and Appwrite, but encountering a 'Realtime got disconnected' issue. The problem might be with the subscribe method setup. Make sure to pass the correct document collection ID and handle the updating of documents correctly.
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more