Closed gr2m closed 7 years ago
🛎 ping @hoodiehq/maintainers this PR is ready for review 👀
I know it’s pretty big, but the changes are pretty repetitive. Because of the new asynchronous initialisation nearly all methods had to be touched to either check if the instance is initiated or to make sure the setup promise is resolved before doing the actual task. And nearly all tests had to be adjusted accordingly
Free kitten hugging gifs for you if you give it a look <3
rebased on #128, closes #127, part of #126
BREAKING CHANGE:
As part of our effort to make Hoodie Client compatible with Service Worker and other environments that do not have access to localStorage, we have to make the Account Client compatible with async store APIs. That means we can’t load the current account state synchronously, so this is no longer be possible:
Starting with this release, you have to wrap the synchronous methods and properties into
account.ready.then()
By default, the account will still use localStorage (via humble-localstorage) to persist its state, but it will now be made asynchronous. In order to use another storage a new
options.store
argument can be passed to the Account constructor:All three
options.store
methods must return promises.store.get
must resolve with the persisted account properties or an empty object.