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
- Appwrite console is too heavy
The Appwrite console is too heavy And all of my services broken Any support , please
- Usage of the new Client() and dealing wi...
Hey guys, just a quick one - we had some web traffic the other day and it ended up bombing out - To put in perspective of how the app works, we have a Nuxt Ap...
- Increase by operators
I see appwrite have bunch of useful operators for querieng db. One more I would like to suggest is operators like increase the count of a int columns by 1,2.. ...