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 will no longer be possible:
var account = new Account({
url: '/api'
})
if (account.isSignedIn()) {
sayHi(account.username)
}
Instead we will have to wrap the synchronous methods and properties into account.ready.then()
account.ready.then(function () {
if (account.isSignedIn()) {
sayHi(account.username)
}
})
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:
var account = new Account({
url: '/api',
store: {
set: writeAccountState
get: getAccountState,
unset: clearAccountState,
}
})
All three options.store methods must return promises
đź“‹ part of https://github.com/hoodiehq/camp/issues/101
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 will no longer be possible:
Instead we will 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