When thinking about Hoodie’s APIs, we always tried to come up with the most simple ones without worrying about complexities in implementation, we call this Dreamcode. One aspect of that simplicity was that some of the API is synchronous, for example
hoodie.account.id
hoodie.account.isSignedIn()
hoodie.store.hasLocalChanges()
hoodie.connectionStatus.ok
We want to keep these APIs, but in order to make that possible, we have to introduce an asynchronous initialisation, similar to jQuery’s ready or serviceWorker.ready, as we realised that we no longer can rely on localStorage, which is the only synchronous API to read/write data.
Our problem with localStorage is that it is not accessible in ServiceWorker. But as we want Hoodie to be a great solution for Offline First applications, we have to make ServiceWorker support a priority.
❓ The Motivation
When thinking about Hoodie’s APIs, we always tried to come up with the most simple ones without worrying about complexities in implementation, we call this Dreamcode. One aspect of that simplicity was that some of the API is synchronous, for example
hoodie.account.id
hoodie.account.isSignedIn()
hoodie.store.hasLocalChanges()
hoodie.connectionStatus.ok
We want to keep these APIs, but in order to make that possible, we have to introduce an asynchronous initialisation, similar to jQuery’s ready or serviceWorker.ready, as we realised that we no longer can rely on localStorage, which is the only synchronous API to read/write data.
Our problem with localStorage is that it is not accessible in ServiceWorker. But as we want Hoodie to be a great solution for Offline First applications, we have to make ServiceWorker support a priority.
So instead of this:
We will from now on have to do
:clipboard: Steps
@hoodie/client-account
: replace undocumentedpre:*
andpost:*
events with a hook API forsignin
andsignout
pre:*
andpost:*
API@hoodie/store-client
.ready
property similar to serviceWorker.ready and.hook.{before,after}('ready', method)
API@hoodie/account-client
@hoodie/connection-status
@hoodie/client
options.store.{get,set,unset}
argument with async get/set/unset methods (default to implementation usinghumble-localstorage
returning promises)@hoodie/account-client
@hoodie/connection-status
.hasLocalChanges()
API from@hoodie/store-client
(https://github.com/hoodiehq/hoodie-store-client/issues/138)@hoodie/account-client
@hoodie/store-client
@hoodie/connection-status
@hoodie/client
hoodie
with new@hoodie/client
and document changeshoodie-app-tracker
with newhoodie
and fix usageLater
@hoodie/account-client
: removeoptions.validate
in favor of asignup
hook