| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of $LIBRARYNAME; | 5 part of $LIBRARYNAME; |
| 6 | 6 |
| 7 $(ANNOTATIONS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { | 7 $(ANNOTATIONS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { |
| 8 | 8 |
| 9 @DomName('IDBObjectStore.put') | 9 @DomName('IDBObjectStore.put') |
| 10 Future put(value, [key]) { | 10 Future put(value, [key]) { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 $!MEMBERS | 79 $!MEMBERS |
| 80 | 80 |
| 81 /** | 81 /** |
| 82 * Helper for iterating over cursors in a request. | 82 * Helper for iterating over cursors in a request. |
| 83 */ | 83 */ |
| 84 static Stream<Cursor> _cursorStreamFromResult(Request request, | 84 static Stream<Cursor> _cursorStreamFromResult(Request request, |
| 85 bool autoAdvance) { | 85 bool autoAdvance) { |
| 86 // TODO: need to guarantee that the controller provides the values | 86 // TODO: need to guarantee that the controller provides the values |
| 87 // immediately as waiting until the next tick will cause the transaction to | 87 // immediately as waiting until the next tick will cause the transaction to |
| 88 // close. | 88 // close. |
| 89 var controller = new StreamController<Cursor>(); | 89 var controller = new StreamController(); |
| 90 | 90 |
| 91 request.onError.listen((e) { | 91 request.onError.listen((e) { |
| 92 //TODO: Report stacktrace once issue 4061 is resolved. | 92 //TODO: Report stacktrace once issue 4061 is resolved. |
| 93 controller.signalError(e); | 93 controller.signalError(e); |
| 94 }); | 94 }); |
| 95 | 95 |
| 96 request.onSuccess.listen((e) { | 96 request.onSuccess.listen((e) { |
| 97 Cursor cursor = request.result; | 97 Cursor cursor = request.result; |
| 98 if (cursor == null) { | 98 if (cursor == null) { |
| 99 controller.close(); | 99 controller.close(); |
| 100 } else { | 100 } else { |
| 101 controller.add(cursor); | 101 controller.add(cursor); |
| 102 if (autoAdvance == true) { | 102 if (autoAdvance == true) { |
| 103 cursor.next(); | 103 cursor.next(); |
| 104 } | 104 } |
| 105 } | 105 } |
| 106 }); | 106 }); |
| 107 return controller.stream; | 107 return controller.stream; |
| 108 } | 108 } |
| 109 } | 109 } |
| OLD | NEW |