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

Side by Side Diff: tools/dom/templates/html/dart2js/indexed_db_dart2js.darttemplate

Issue 23681003: added library-level description for dart:indexed_db (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fixed code sample that opens a DB to show a little more Created 7 years, 3 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 // DO NOT EDIT - unless you are editing documentation as per: 5 // DO NOT EDIT - unless you are editing documentation as per:
6 // https://code.google.com/p/dart/wiki/ContributingHTMLDocumentation 6 // https://code.google.com/p/dart/wiki/ContributingHTMLDocumentation
7 // Auto-generated dart:svg library. 7 // Auto-generated dart:svg library.
8 8
9 /**
10 * A client-side key-value store with support for indexes.
11 *
12 * Many browsers support IndexedDB—a web standard for
13 * an indexed database.
14 * By storing data on the client in an IndexedDB,
15 * a web app gets some advantages, such as faster performance and persistence.
16 * To find out which browsers support IndexedDB,
17 * refer to [Can I Use?](http://caniuse.com/#feat=indexeddb)
18 *
19 * In IndexedDB, each record is identified by a unique index or key,
20 * making data retrieval speedy.
21 * You can store structured data,
22 * such as images, arrays, and maps using IndexedDB.
23 * The standard does not specify size limits for individual data items
24 * or for the database itself, but browsers may impose storage limits.
25 *
26 * ## Using indexed_db
27 *
28 * The classes in this library provide an interface
29 * to the browser's IndexedDB, if it has one.
30 * To use this library in your code:
31 *
32 * import 'dart:indexed_db';
33 *
34 * A web app can determine if the browser supports
35 * IndexedDB with [IdbFactory.supported]:
36 *
37 * if (IdbFactory.supported)
38 * // Use indexeddb.
39 * else
40 * // Find an alternative.
41 *
42 * Access to the browser's IndexedDB is provided by the app's top-level
43 * [Window] object, which your code can refer to with `window.indexedDB`.
44 * So, for example,
45 * here's how to use window.indexedDB to open a database:
46 *
47 * Future open() {
48 * return window.indexedDB.open('myIndexedDB',
49 * version: 1,
50 * onUpgradeNeeded: _initializeDatabase)
51 * .then(_loadFromDB);
52 * }
53 * void _initializeDatabase(VersionChangeEvent e) {
54 * ...
55 * }
56 * Future _loadFromDB(Database db) {
57 * ...
58 * }
59 *
60 *
61 * All data in an IndexedDB is stored within an [ObjectStore].
62 * To manipulate the database use [Transaction]s.
63 *
64 * ## Other resources
65 *
66 * Other options for client-side data storage include:
67 *
68 * * [Window.localStorage]—a
69 * basic mechanism in which data is stored as a [Map].
70 *
71 * * [dart:web_sql]—a database that can be queried with SQL.
72 *
73 * * The [Lawndart](http://pub.dartlang.org/packages/lawndart) package,
74 * which helps you deal with the wide array of client-side storage options.
75 *
76 * For a tutorial about using the indexed_db library with Dart,
77 * check out
78 * [Use IndexedDB](http://www.dartlang.org/docs/tutorials/indexeddb/).
79 *
80 * [IndexedDB reference](http://docs.webplatform.org/wiki/apis/indexeddb)
81 * provides wiki-style docs about indexedDB
82 */
9 library dart.dom.indexed_db; 83 library dart.dom.indexed_db;
10 84
11 import 'dart:async'; 85 import 'dart:async';
12 import 'dart:html'; 86 import 'dart:html';
13 import 'dart:html_common'; 87 import 'dart:html_common';
14 import 'dart:typed_data'; 88 import 'dart:typed_data';
15 import 'dart:_js_helper' show Creates, Returns, JSName, Null; 89 import 'dart:_js_helper' show Creates, Returns, JSName, Null;
16 import 'dart:_foreign_helper' show JS; 90 import 'dart:_foreign_helper' show JS;
17 import 'dart:_interceptors' show Interceptor, JSExtendableArray; 91 import 'dart:_interceptors' show Interceptor, JSExtendableArray;
18 92
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 199
126 /// May modify original. If so, action is idempotent. 200 /// May modify original. If so, action is idempotent.
127 _convertNativeToDart_IDBAny(object) { 201 _convertNativeToDart_IDBAny(object) {
128 return convertNativeToDart_AcceptStructuredClone(object, mustCopy: false); 202 return convertNativeToDart_AcceptStructuredClone(object, mustCopy: false);
129 } 203 }
130 204
131 // TODO(sra): Add DateTime. 205 // TODO(sra): Add DateTime.
132 const String _idbKey = 'JSExtendableArray|=Object|num|String'; 206 const String _idbKey = 'JSExtendableArray|=Object|num|String';
133 const _annotation_Creates_IDBKey = const Creates(_idbKey); 207 const _annotation_Creates_IDBKey = const Creates(_idbKey);
134 const _annotation_Returns_IDBKey = const Returns(_idbKey); 208 const _annotation_Returns_IDBKey = const Returns(_idbKey);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698