GSI - Employe Self Service Mobile
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
3.0 KiB

2 months ago
  1. # Breaking changes in 7.x
  2. - No longer committing `build` to GitHub.
  3. - Renamed files in dist.
  4. - Added conditional exports.
  5. - iife build is now a umd.
  6. # Breaking changes in 6.x
  7. Some TypeScript definitions changed so write-methods are missing from 'readonly' transactions. This might be backwards-incompatible with code that performs a lot of type wrangling.
  8. # Breaking changes in 5.x
  9. I moved some files around, so I bumped the major version for safety.
  10. # Changes in 4.x
  11. ## Breaking changes
  12. ### Opening a database
  13. ```js
  14. // Old 3.x way
  15. import { openDb } from 'idb';
  16. openDb('db-name', 1, (upgradeDb) => {
  17. console.log(upgradeDb.oldVersion);
  18. console.log(upgradeDb.transaction);
  19. });
  20. ```
  21. ```js
  22. // New 4.x way
  23. import { openDB } from 'idb';
  24. openDB('db-name', 1, {
  25. upgrade(db, oldVersion, newVersion, transaction) {
  26. console.log(oldVersion);
  27. console.log(transaction);
  28. },
  29. });
  30. ```
  31. - `openDb` and `deleteDb` were renamed `openDB` and `deleteDB` to be more consistent with DOM naming.
  32. - The signature of `openDB` changed. The third parameter used to be the upgrade callback, it's now an option object which can include an `upgrade` method.
  33. - There's no `UpgradeDB` anymore. You get the same database `openDB` resolves with. Versions numbers and the upgrade transaction are included as additional parameters.
  34. ### Promises & throwing
  35. The library turns all `IDBRequest` objects into promises, but it doesn't know in advance which methods may return promises.
  36. As a result, methods such as `store.put` may throw instead of returning a promise.
  37. If you're using async functions, there isn't a difference.
  38. ### Other breaking changes
  39. - `iterateCursor` and `iterateKeyCursor` have been removed. These existed to work around browsers microtask issues which have since been fixed. Async iterators provide similar functionality.
  40. - All pseudo-private properties (those beginning with an underscore) are gone. Use `unwrap()` to get access to bare IDB objects.
  41. - `transaction.complete` was renamed to `transaction.done` to be shorter and more consistent with the DOM.
  42. - `getAll` is no longer polyfilled on indexes and stores.
  43. - The library no longer officially supports IE11.
  44. ## New stuff
  45. - The library now uses proxies, so objects will include everything from their plain-IDB equivalents.
  46. - TypeScript support has massively improved, including the ability to provide types for your database.
  47. - Optional support for async iterators, which makes handling cursors much easier.
  48. - Database objects now have shortcuts for single actions (like `get`, `put`, `add`, `getAll` etc etc).
  49. - For transactions that cover a single store `transaction.store` is a reference to that store.
  50. - `openDB` lets you add callbacks for when your database is blocking another connection, or when you're blocked by another connection.
  51. # Changes in 3.x
  52. The library became a module.
  53. ```js
  54. // Old 2.x way:
  55. import idb from 'idb';
  56. idb.open(…);
  57. idb.delete(…);
  58. // 3.x way:
  59. import { openDb, deleteDb } from 'idb';
  60. openDb(…);
  61. deleteDb(…);
  62. ```