Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(328)

Unified Diff: dart/samples/dartiverse_search/stack_overflow_search_engine.dart

Issue 60293003: Version 0.8.10.5 (Closed) Base URL: http://dart.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « dart/samples/dartiverse_search/search_engine.dart ('k') | dart/samples/dartiverse_search/web/client.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/samples/dartiverse_search/stack_overflow_search_engine.dart
===================================================================
--- dart/samples/dartiverse_search/stack_overflow_search_engine.dart (revision 29908)
+++ dart/samples/dartiverse_search/stack_overflow_search_engine.dart (working copy)
@@ -1,39 +0,0 @@
-// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-part of dartiverse_search;
-
-
-class StackOverflowSearchEngine {
- String get name => 'StackOverflow';
-
- Stream<SearchResult> search(String input) {
- var query = {
- 'site': 'stackoverflow',
- 'tagged': 'dart',
- 'intitle': input,
- 'sort': 'relevance',
- 'order': 'desc',
- 'pagesize': '3'
- };
- var searchUri = new Uri.https(
- 'api.stackexchange.com',
- '/2.1/search',
- query);
- var controller = new StreamController();
- http_client.get(searchUri)
- .then((response) {
- if (response.statusCode != HttpStatus.OK) throw "Bad status code.";
- var json = JSON.decode(response.body);
- json.putIfAbsent('items', () => []);
- json['items'].take(3).forEach((item) {
- controller.add(new SearchResult(
- item['title'], item['link']));
- });
- })
- .catchError(controller.addError)
- .whenComplete(controller.close);
- return controller.stream;
- }
-}
« no previous file with comments | « dart/samples/dartiverse_search/search_engine.dart ('k') | dart/samples/dartiverse_search/web/client.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698