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
- createSession() fails on Linux but works...
Hey Guys i need some help with this one. Am building for web and desktop using different code bases. For web am using Nuxt, and for desktop(windows and linux) a...
- Can Sites deployments be limited to the ...
Hey all! I’m using Appwrite Cloud Sites with GitHub connected. Right now, Appwrite seems to build for every push and PR, not just for my production branch (main...
- [Sites] pnpm Turborepo monorepo — stuck ...
deployment seems to never finish. Testing Appwrite Sites with a standard pnpm Turborepo monorepo (npx create-turbo@latest). Repo: https://github.com/saitrogen/...