Proper event listener for listening to a specific document in a collection? (Realtime)
- 0
- Realtime
In order to get notifications (per user) I set it up to subscribe to any event taken place in their respective document in a collection. I first subscribe to the collection then listen via "databases..collections..documents". My only issue is that when I change something in the document I am not getting anything printed. The following code :void subscribe() async {
final String getId = Boxes.getMainUser().values.first.id;
subscription = ApiService.instance!.realTime.subscribe([
'databases.[637044216b476709d41d].collections.[63704487a16832bfd730].documents.[$getId]'
]);
subscription.stream.listen((response) {
print("SOmehting happening");
if (response.events.contains('databases.*.collections.*.documents')) {
print("SOmehting happening");
}
});
}
Hi there 👋
Are you seeing no output in your local console?
Correct, I am not seeing any output in the terminal
Can you try removing the extra brackets around the IDs
databases.637044216b476709d41d.collections.63704487a16832bfd730.documents
The channel Should be this
You guys are live savers!
Big help. I don't know if this is an error but when I was using the event listeners in the document it wasn't working so I just printed the response from real-time to see what the actual event key is structured. The docs is structured via databases.*.collections.*.documents.update but the working key is databases.*.collections.*.documents.*.update.
Channel != Events
Correct, I was just meaning it in general.
Oh sorry I think I see what you mean now. The docs (https://appwrite.io/docs/events#databases-events) say there's an event like ...documents.update but there isn't.
Cc @VincentGe
?>>?????
Wait there is no update event?
LOL
These are auto generated. I will have to dig into this on monday
:sadge
There should be an ID or wildcard between document and update
Yikes :/
JE see
Recommended threads
- Realtime: Listener not triggered on upda...
I self host appwrite 1.8.1. The genereal functionallity works fine. But my realtime subscription isn't updating. I see "Received heartbeat response from realtim...
- Realtime for files() works almost well, ...
I have been trying to make use of realtime, today (14.03.26) I have pulled all the latest versions of docker images, and sdk available. Whats working: - Conn...
- 🐛 Realtime Flutter SDK Crash – Realtime...
**Summary** When using Appwrite Cloud with the Flutter SDK (latest appwrite release: 21.4.0), Realtime crashes with: ```Unhandled async error: type '_Map<String...