Skip to content

Commit

Permalink
chore: adapt to @hoodie/client@10
Browse files Browse the repository at this point in the history
  • Loading branch information
gr2m committed Mar 9, 2017
1 parent 9d636fa commit d8d9c86
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
13 changes: 7 additions & 6 deletions docs/api/client/hoodie.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@ Initialisation
--------------

The Hoodie Client persists state in the browser, like the current user’s
id, session or the connection status to the backend. On page load,
Hoodie has to load this state from the local store before you can use
its APIs. You can use the Promise returned by ``hoodie.ready`` to wait
until all APIs are fully initialised
id, session or the connection status to the backend.

.. code:: js
hoodie.ready.then(function () {
// all hoodie APIs are ready now
hoodie.account.get('session').then(function (session) {
if (session) {
// user is signed in
} else {
// user is signed out
}
})
This is work in progress
Expand Down
4 changes: 2 additions & 2 deletions public/account/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ document.querySelector('body').addEventListener('click', function (event) {
}
})

hoodie.ready.then(function () {
hoodie.account.get('session').then(function (session) {
// Client Rendering Logic
if (hoodie.account.isSignedIn()) {
if (session) {
document.querySelector('.generic-loader-wrap').setAttribute('data-hide', 'true')
document.querySelectorAll('.profile-forms').forEach(function (node) {
return node.setAttribute('data-hide', 'false')
Expand Down

0 comments on commit d8d9c86

Please sign in to comment.