UI for Zipcoin Blue

storage.d.ts 5.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. /// <reference types="localforage" />
  2. import { InjectionToken } from '@angular/core';
  3. /**
  4. * Storage is an easy way to store key/value pairs and JSON objects.
  5. * Storage uses a variety of storage engines underneath, picking the best one available
  6. * depending on the platform.
  7. *
  8. * When running in a native app context, Storage will prioritize using SQLite, as it's one of
  9. * the most stable and widely used file-based databases, and avoids some of the
  10. * pitfalls of things like localstorage and IndexedDB, such as the OS deciding to clear out such
  11. * data in low disk-space situations.
  12. *
  13. * When running in the web or as a Progressive Web App, Storage will attempt to use
  14. * IndexedDB, WebSQL, and localstorage, in that order.
  15. *
  16. * @usage
  17. * First, if you'd like to use SQLite, install the cordova-sqlite-storage plugin:
  18. * ```bash
  19. * ionic cordova plugin add cordova-sqlite-storage
  20. * ```
  21. *
  22. * Next, install the package (comes by default for Ionic apps > Ionic V1):
  23. * ```bash
  24. * npm install --save @ionic/storage
  25. * ```
  26. *
  27. * Next, add it to the imports list in your `NgModule` declaration (for example, in `src/app/app.module.ts`):
  28. *
  29. * ```typescript
  30. * import { IonicStorageModule } from '@ionic/storage';
  31. *
  32. * @NgModule({
  33. * declarations: [
  34. * // ...
  35. * ],
  36. * imports: [
  37. * BrowserModule,
  38. * IonicModule.forRoot(MyApp),
  39. * IonicStorageModule.forRoot()
  40. * ],
  41. * bootstrap: [IonicApp],
  42. * entryComponents: [
  43. * // ...
  44. * ],
  45. * providers: [
  46. * // ...
  47. * ]
  48. * })
  49. * export class AppModule {}
  50. *```
  51. *
  52. * Finally, inject it into any of your components or pages:
  53. * ```typescript
  54. * import { Storage } from '@ionic/storage';
  55. * export class MyApp {
  56. * constructor(private storage: Storage) { }
  57. *
  58. * ...
  59. *
  60. * // set a key/value
  61. * storage.set('name', 'Max');
  62. *
  63. * // Or to get a key/value pair
  64. * storage.get('age').then((val) => {
  65. * console.log('Your age is', val);
  66. * });
  67. * }
  68. * ```
  69. *
  70. *
  71. * ### Configuring Storage
  72. *
  73. * The Storage engine can be configured both with specific storage engine priorities, or custom configuration
  74. * options to pass to localForage. See the localForage config docs for possible options: https://github.com/localForage/localForage#configuration
  75. *
  76. * Note: Any custom configurations will be merged with the default configuration
  77. *
  78. * ```typescript
  79. * import { IonicStorageModule } from '@ionic/storage';
  80. *
  81. * @NgModule({
  82. * declarations: [...],
  83. * imports: [
  84. * IonicStorageModule.forRoot({
  85. * name: '__mydb',
  86. driverOrder: ['indexeddb', 'sqlite', 'websql']
  87. * })
  88. * ],
  89. * bootstrap: [...],
  90. * entryComponents: [...],
  91. * providers: [...]
  92. * })
  93. * export class AppModule { }
  94. * ```
  95. */
  96. export declare class Storage {
  97. private _dbPromise;
  98. private _driver;
  99. /**
  100. * Create a new Storage instance using the order of drivers and any additional config
  101. * options to pass to LocalForage.
  102. *
  103. * Possible driver options are: ['sqlite', 'indexeddb', 'websql', 'localstorage'] and the
  104. * default is that exact ordering.
  105. */
  106. constructor(config: StorageConfig);
  107. /**
  108. * Get the name of the driver being used.
  109. * @returns {string | null} Name of the driver
  110. */
  111. readonly driver: string;
  112. /**
  113. * Reflect the readiness of the store.
  114. * @returns {Promise<LocalForage>} Returns a promise that resolves when the store is ready
  115. */
  116. ready(): Promise<LocalForage>;
  117. _getDriverOrder(driverOrder: any): any;
  118. /**
  119. * Get the value associated with the given key.
  120. * @param {any} key the key to identify this value
  121. * @returns {Promise} Returns a promise with the value of the given key
  122. */
  123. get(key: string): Promise<any>;
  124. /**
  125. * Set the value for the given key.
  126. * @param {any} key the key to identify this value
  127. * @param {any} value the value for this key
  128. * @returns {Promise} Returns a promise that resolves when the key and value are set
  129. */
  130. set(key: string, value: any): Promise<any>;
  131. /**
  132. * Remove any value associated with this key.
  133. * @param {any} key the key to identify this value
  134. * @returns {Promise} Returns a promise that resolves when the value is removed
  135. */
  136. remove(key: string): Promise<any>;
  137. /**
  138. * Clear the entire key value store. WARNING: HOT!
  139. * @returns {Promise} Returns a promise that resolves when the store is cleared
  140. */
  141. clear(): Promise<void>;
  142. /**
  143. * @returns {Promise} Returns a promise that resolves with the number of keys stored.
  144. */
  145. length(): Promise<number>;
  146. /**
  147. * @returns {Promise} Returns a promise that resolves with the keys in the store.
  148. */
  149. keys(): Promise<string[]>;
  150. /**
  151. * Iterate through each key,value pair.
  152. * @param {any} iteratorCallback a callback of the form (value, key, iterationNumber)
  153. * @returns {Promise} Returns a promise that resolves when the iteration has finished.
  154. */
  155. forEach(iteratorCallback: (value: any, key: string, iterationNumber: Number) => any): Promise<void>;
  156. }
  157. /** @hidden */
  158. export declare function getDefaultConfig(): {
  159. name: string;
  160. storeName: string;
  161. driverOrder: string[];
  162. };
  163. /** @hidden */
  164. export interface StorageConfig {
  165. name?: string;
  166. storeName?: string;
  167. driverOrder?: string[];
  168. }
  169. /** @hidden */
  170. export declare const StorageConfigToken: InjectionToken<{}>;
  171. /** @hidden */
  172. export declare function provideStorage(storageConfig: StorageConfig): Storage;