Slide 21
Slide 21 text
1 class BleManager extends EventEmitter2 {
2 startScanning() { /* snip */ }
3 connectToPeripheral() { /* snip */ }
4 async readCharacteristic() { /* snip */ }
5 async startMeasuring() {
6 const value = await this.readCharacteristic()
7 this.emit('READ', value)
8 }
9 }
1 class SomeComponent extends React.Component {
2 handleRead(value) {
3 this.props.actions.storeValues(value)
4 }
5 componentDidMount() {
6 this.props.bleManager.on(
7 'READ',
8 this.handleRead.bind(this)
9 )
10 }
11 render() {
12 /* render buttons to
13 * - startScanning
14 * - connectToPeripheral,
15 * - startMeasuring */
16 }
17 }