Skip to content

Commit

Permalink
Merge pull request #25 from Bonemind/master
Browse files Browse the repository at this point in the history
Added removeListener to BluetoothSerial
  • Loading branch information
rusel1989 authored Feb 21, 2017
2 parents b637281 + e9f3077 commit c363841
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ Currently provided events are:
- `connectionSuccess` - when app connected to device
- `connectionLost` - when app lost connection to device (fired with `bluetoothDisabled`)
You can use `BluetoothSerial.removeListener(eventName, callback)` to stop listening to an event
## TODO
- Make services configurable on ios
Expand Down
9 changes: 9 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ BluetoothSerial.on = (eventName, handler) => {
DeviceEventEmitter.addListener(eventName, handler)
}

/**
* Stop listening for event
* @param {String} eventName Name of event one of connectionSuccess, connectionLost, data, rawData
* @param {Function} handler Event handler
*/
BluetoothSerial.removeListener = (eventName, handler) => {
DeviceEventEmitter.removeListener(eventName, handler)
}

/**
* Write data to device, you can pass string or buffer,
* We must convert to base64 in RN there is no way to pass buffer directly
Expand Down

0 comments on commit c363841

Please sign in to comment.