Skip to content

Commit 13385fe

Browse files
committed
autocomplete [nfc]: Document semantics of query and results on view-model
1 parent 777245f commit 13385fe

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

lib/model/autocomplete.dart

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,15 @@ abstract class AutocompleteView<QueryT extends AutocompleteQuery, ResultT extend
208208

209209
final PerAccountStore store;
210210

211+
/// The last query this [AutocompleteView] was asked to perform for the user.
212+
///
213+
/// If this view-model is currently performing a search,
214+
/// the search is for this query.
215+
/// If not, then [results] reflect this query.
216+
///
217+
/// When set, the existing query is aborted if still in progress,
218+
/// and a search for the new query is begun.
219+
/// Any existing value in [results] remains until the new query finishes.
211220
QueryT get query => _query;
212221
QueryT _query;
213222
set query(QueryT query) {
@@ -222,6 +231,13 @@ abstract class AutocompleteView<QueryT extends AutocompleteQuery, ResultT extend
222231
_startSearch();
223232
}
224233

234+
/// The latest set of results available for any value of [query].
235+
///
236+
/// When this changes, listeners will be notified with [notifyListeners].
237+
///
238+
/// These results might not correspond to the current value of [query],
239+
/// if a search is still in progress.
240+
/// Before any search completes, [results] will be empty.
225241
Iterable<ResultT> get results => _results;
226242
List<ResultT> _results = [];
227243

0 commit comments

Comments
 (0)