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.add') | 9 @DomName('IDBObjectStore.add') |
10 Future add(value, [key]) { | 10 Future add(value, [key]) { |
11 try { | 11 try { |
12 var request; | 12 var request; |
13 if (key != null) { | 13 if (key != null) { |
14 request = $dom_add(value, key); | 14 request = $dom_add(value, key); |
15 } else { | 15 } else { |
16 request = $dom_add(value); | 16 request = $dom_add(value); |
17 } | 17 } |
18 return _completeRequest(request); | 18 return _completeRequest(request); |
19 } catch (e, stacktrace) { | 19 } catch (e, stacktrace) { |
20 return new Future.immediateError(e, stacktrace); | 20 return new Future.error(e, stacktrace); |
21 } | 21 } |
22 } | 22 } |
23 | 23 |
24 @DomName('IDBObjectStore.clear') | 24 @DomName('IDBObjectStore.clear') |
25 Future clear() { | 25 Future clear() { |
26 try { | 26 try { |
27 return _completeRequest($dom_clear()); | 27 return _completeRequest($dom_clear()); |
28 } catch (e, stacktrace) { | 28 } catch (e, stacktrace) { |
29 return new Future.immediateError(e, stacktrace); | 29 return new Future.error(e, stacktrace); |
30 } | 30 } |
31 } | 31 } |
32 | 32 |
33 @DomName('IDBObjectStore.delete') | 33 @DomName('IDBObjectStore.delete') |
34 Future delete(key_OR_keyRange){ | 34 Future delete(key_OR_keyRange){ |
35 try { | 35 try { |
36 return _completeRequest($dom_delete(key_OR_keyRange)); | 36 return _completeRequest($dom_delete(key_OR_keyRange)); |
37 } catch (e, stacktrace) { | 37 } catch (e, stacktrace) { |
38 return new Future.immediateError(e, stacktrace); | 38 return new Future.error(e, stacktrace); |
39 } | 39 } |
40 } | 40 } |
41 | 41 |
42 @DomName('IDBObjectStore.count') | 42 @DomName('IDBObjectStore.count') |
43 Future<int> count([key_OR_range]) { | 43 Future<int> count([key_OR_range]) { |
44 try { | 44 try { |
45 var request; | 45 var request; |
46 if (key_OR_range != null) { | 46 if (key_OR_range != null) { |
47 request = $dom_count(key_OR_range); | 47 request = $dom_count(key_OR_range); |
48 } else { | 48 } else { |
49 request = $dom_count(); | 49 request = $dom_count(); |
50 } | 50 } |
51 return _completeRequest(request); | 51 return _completeRequest(request); |
52 } catch (e, stacktrace) { | 52 } catch (e, stacktrace) { |
53 return new Future.immediateError(e, stacktrace); | 53 return new Future.error(e, stacktrace); |
54 } | 54 } |
55 } | 55 } |
56 | 56 |
57 @DomName('IDBObjectStore.put') | 57 @DomName('IDBObjectStore.put') |
58 Future put(value, [key]) { | 58 Future put(value, [key]) { |
59 try { | 59 try { |
60 var request; | 60 var request; |
61 if (key != null) { | 61 if (key != null) { |
62 request = $dom_put(value, key); | 62 request = $dom_put(value, key); |
63 } else { | 63 } else { |
64 request = $dom_put(value); | 64 request = $dom_put(value); |
65 } | 65 } |
66 return _completeRequest(request); | 66 return _completeRequest(request); |
67 } catch (e, stacktrace) { | 67 } catch (e, stacktrace) { |
68 return new Future.immediateError(e, stacktrace); | 68 return new Future.error(e, stacktrace); |
69 } | 69 } |
70 } | 70 } |
71 | 71 |
72 @DomName('IDBObjectStore.get') | 72 @DomName('IDBObjectStore.get') |
73 Future getObject(key) { | 73 Future getObject(key) { |
74 try { | 74 try { |
75 var request = $dom_get(key); | 75 var request = $dom_get(key); |
76 | 76 |
77 return _completeRequest(request); | 77 return _completeRequest(request); |
78 } catch (e, stacktrace) { | 78 } catch (e, stacktrace) { |
79 return new Future.immediateError(e, stacktrace); | 79 return new Future.error(e, stacktrace); |
80 } | 80 } |
81 } | 81 } |
82 | 82 |
83 /** | 83 /** |
84 * Creates a stream of cursors over the records in this object store. | 84 * Creates a stream of cursors over the records in this object store. |
85 * | 85 * |
86 * **The stream must be manually advanced by calling [Cursor.next] after | 86 * **The stream must be manually advanced by calling [Cursor.next] after |
87 * each item or by specifying autoAdvance to be true.** | 87 * each item or by specifying autoAdvance to be true.** |
88 * | 88 * |
89 * var cursors = objectStore.openCursor().listen( | 89 * var cursors = objectStore.openCursor().listen( |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 } else { | 161 } else { |
162 controller.add(cursor); | 162 controller.add(cursor); |
163 if (autoAdvance == true && controller.hasListener) { | 163 if (autoAdvance == true && controller.hasListener) { |
164 cursor.next(); | 164 cursor.next(); |
165 } | 165 } |
166 } | 166 } |
167 }); | 167 }); |
168 return controller.stream; | 168 return controller.stream; |
169 } | 169 } |
170 } | 170 } |
OLD | NEW |