I am trying to connect to realtime database updates but don't seem to receive any updates. Documentation is pretty bad and i am stuck. Can anyone help? Here is what i am trying with, maybe i am stupid:
TypeScript
useEffect(() => {
loadElements();
if (!projectData) return;
let subscription;
const setupRealtime = async () => {
const subscription = await realtime.subscribe(Channel.tablesdb(), response => {
if (response.events.includes('databases.*.elements.*.update')) {
console.log(response.payload);
}
});
}
setupRealtime();
}, [projectData]);
TL;DR
Developers having trouble receiving updates from their realtime database while using the code snippet provided. They suspect the issue may be due to poor documentation. Here's a suggested solution:
The issue in the code is that a new variable `subscription` is being defined within the `setupRealtime` function instead of updating the one declared outside. To fix this, remove the `let` before `subscription` in `setupRealtime` function. This way, it will update the outer variable properly and receive updates from the realtime database.Recommended threads
- How to Display File in Web?
I'm trying to use Appwrite's Storage to store images and display them in my app, however when I use the `getFileView`, `getFileDownload` or `getFilePreview` met...
- Project Paused Despite Daily Active Usag...
I noticed that my project was automatically **paused**, even though it is actively being used. The project is an **attendance application** that is used daily b...
- Sudden CORS Errors - Domain hasn't Chang...
I have an Appwrite project with two web apps configured, the first one has the hostname `*` and the second one I just added to test if it could fix the issue wi...