W3C home > Mailing lists > Public > public-web-bluetooth-log@w3.org > June 2016

Re: [web-bluetooth] How to add disconnect event handler

From: François Beaufort via GitHub <sysbot+gh@w3.org>
Date: Tue, 14 Jun 2016 18:58:47 +0000
To: public-web-bluetooth-log@w3.org
Message-ID: <issue_comment.created-225982137-1465930727-sysbot+gh@w3.org>
In your code, here's how it should look like:

```js
        navigator.bluetooth.requestDevice(options)
            .then(function ( device ) {
                console.log('Name: ' + device.name);
                device.addEventListener( 'gattserverdisconnected', 
handleDisconnect );
                return device.gatt.connect();
            })
            .then(function ( server ) {
                console.log('server ' + server );
                return server.getPrimaryService( MESH_SERVICE_UUID );
            })

-- 
GitHub Notification of comment by beaufortfrancois
Please view or discuss this issue at 
https://github.com/WebBluetoothCG/web-bluetooth/issues/244#issuecomment-225982137
 using your GitHub account
Received on Tuesday, 14 June 2016 18:58:49 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 14 June 2016 18:58:49 UTC