[firebase_database] Add a getter in Query which return full path with query's parameters #5616
Unanswered
XenoMACHINE
asked this question in
Feature request
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Description
I'm always frustrated when i want to manage queries listeners.
Example
I want many queries listeners like this
final query1 = FirebaseDatabase.instance.reference().child("users").orderByChild("uid").equalTo(UID1); final query2 = FirebaseDatabase.instance.reference().child("users").orderByChild("uid").equalTo(UID2);
I launch and store listeners like this :
Map<String, StreamSubscription<Event>> launchedQueries = Map(); launchedQueries[query.path] = query1.onValue.listen((event) => onData(event.snapshot)); launchedQueries[query.path] = query2.onValue.listen((event) => onData(event.snapshot));
The problem is that both queries.path return "users". But they are different (parameters are not same, UID1 / UID2 ).
I do that in order to manage properly my listeners, to have one listener for each query and to cancel a listener easily with a given query.
Solution
Add a getter in Query like
String get fullPath => '$path/${_parameters.entries.map((e) => '${e.key}/${e.value}').join('/')}';
Or just set _parameters to public.
Beta Was this translation helpful? Give feedback.
All reactions