rethinkdb / horizon-docs

Other
24 stars 36 forks source link

It's now possible to get the handshake value from the horizon object #81

Open deontologician opened 8 years ago

deontologician commented 8 years ago

We have a subobject for every horizon instance called utensils (not sure if documented). It now has a new attribute, handshake which will get you raw access to the handshake information.

Everything in .utensils is considered a low-level api, so we probably should have a special page for it or something, rather than documenting it with everything else. The utensils api is also intended to be for things that are a bit less stable or internal.

Example of handshake:

horizon.utensils.handshake.subscribe((handshake) => {
 console.log('UserId is:', handshake.id)
})

It has a few fields in it, but the only one we should document right now is id, which is the currently logged in userId. The other fields are unstable and subject to change.

Also note that subscribing to .handshake won't cause a connection to the server, it only returns once the handshake has occurred. To force a connection, you still need to use horizon.connect() or some other query

chipotle commented 8 years ago

utensils isn't documented, so it sounds like this may belong on the page for utensils that isn't there, and that page needs to be linked from the Horizon object API page as well as the sidebar.

danielmewes commented 8 years ago

@deontologician Is there a benefit of using the user id from the handshake over getting it from currentUser (http://horizon.io/api/horizon/#currentuser)? If the utensils object is not part of the official API and everything you can get from it is also available through stable API functions, I'm not sure if we should even document it at all.