Skip to content

v5.0.0

Compare
Choose a tag to compare
@hoodiebot hoodiebot released this 23 Dec 04:24

<a name"5.0.0">

5.0.0 (2016-12-23)

Features

Breaking Changes

  • 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:
var account = new Account({
  url: /api
})
if (account.isSignedIn()) {
  sayHi(account.username)
}

Starting with this release, you 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.cache argument can be passed to the Account constructor:

var account = new Account({
  url: /api,
  cache: {
    set: writeAccountState
    get: getAccountState,
    unset: clearAccountState,
  }
})

All three options.cache methods must return promises. options.cache.get must resolve with the persisted account properties or an empty object.

(962841a2)

The pre:* and post:* events introduced in #65 have now been removed in favor of a proper account.hook.{before,after} API. See https://github.com/hoodiehq/hoodie-account-client#hooks for more details.

This is not technically a breaking change as the pre:* and post:* events have not been documented, but as they are used by @hoodie/client we decided to make this a breaking change nevertheless

(72f79c20)