Handbid-Js
I am the Handbid
library. I work in both nodejs && in the browser. I rely on chai
for my tests. To be honest, I've never run any unit tests in the browser, someone should figure out how to do that. =)
Lifecycle
Connecting to an auction in Handbid is a multi-step process. It's pretty simple though, here is a breakdown:
- Instantiate new Handbid instance:
var hb = new Handbid()
- Connect to the
main
server by invoking:hb.connect();
- Connect to any auction by key by invoking:
hb.connectToAuction('any-auction-key');
- Listen for auction connection:
hb.on('did-connect-to-auction', function (e) { console.log(e.get('auction')); });
You can invoke connectToAuction()
immediately after connect()
(you don't have to wait for the main connection to be established).
Examples
Here are some code samples to get you started!
Nodejs
$npm install handbid
var Handbid = hb = ; hb;hb; //from this point it's exactly the same as the browser examples.
Browser
Authentication
Events
Under each event name is a description of the data passed with the event. This event is the single object passed to a listener of any event.
hb;
Handbid
did-connect-to-server
: when a server connection is made after invokinghb.connect()
handbid
: instance that dispatched the eventurl
: the url we connected to
did-connect-to-auction
: dispatched afterhb.connectToAuction('auction-key')
handbid
: instance that dispatched the eventauction
: the auction we connected to
did-receive-message
: whenever the current user gets a messagemessage
: text of message that was sent
error
: anytime any error occurs
Handbid API
- `
Connect Button
Throwing in a connect button is wicked easy!