waitForRoomInSync method
Wait for the room to appear into the enabled section of the room sync. By default, the function will listen for room in invite, join and leave sections of the sync.
Implementation
Future<SyncUpdate> waitForRoomInSync(String roomId,
{bool join = false, bool invite = false, bool leave = false}) async {
if (!join && !invite && !leave) {
join = true;
invite = true;
leave = true;
}
return await onSync.stream.firstWhere((sync) =>
invite && (sync.rooms?.invite?.containsKey(roomId) ?? false) ||
join && (sync.rooms?.join?.containsKey(roomId) ?? false) ||
leave && (sync.rooms?.leave?.containsKey(roomId) ?? false));
}