@@ -56,6 +56,8 @@ class BeaconsDemo extends Component {
5656 // check bluetooth state:
5757 bluetoothState : '' ,
5858
59+ message : '' ,
60+
5961 beaconsLists : new ListView . DataSource ( {
6062 rowHasChanged : ( r1 , r2 ) => r1 !== r2 ,
6163 sectionHeaderHasChanged : ( s1 , s2 ) => s1 !== s2
@@ -98,7 +100,8 @@ class BeaconsDemo extends Component {
98100 DeviceEventEmitter . addListener (
99101 'beaconsDidRange' ,
100102 ( data ) => {
101- console . log ( 'beaconsDidRange, data: ' , data ) ;
103+ this . setState ( { message : 'beaconsDidRange event' } ) ;
104+ // console.log('beaconsDidRange, data: ', data);
102105 const updatedBeaconsLists = this . updateBeaconList ( data . beacons , 'rangingList' ) ;
103106 this . _beaconsLists = updatedBeaconsLists ;
104107 this . setState ( { beaconsLists : this . state . beaconsLists . cloneWithRowsAndSections ( this . _beaconsLists ) } ) ;
@@ -109,6 +112,7 @@ class BeaconsDemo extends Component {
109112 DeviceEventEmitter . addListener (
110113 'regionDidEnter' ,
111114 ( { uuid, identifier} ) => {
115+ this . setState ( { message : 'regionDidEnter event' } ) ;
112116 console . log ( 'regionDidEnter, data: ' , { uuid, identifier} ) ;
113117 const time = moment ( ) . format ( TIME_FORMAT ) ;
114118 const updatedBeaconsLists = this . updateBeaconList ( { uuid, identifier, time} , 'monitorEnterList' ) ;
@@ -119,6 +123,7 @@ class BeaconsDemo extends Component {
119123 DeviceEventEmitter . addListener (
120124 'regionDidExit' ,
121125 ( { identifier, uuid, minor, major } ) => {
126+ this . setState ( { message : 'regionDidExit event' } ) ;
122127 console . log ( 'regionDidExit, data: ' , { identifier, uuid, minor, major} ) ;
123128 const time = moment ( ) . format ( TIME_FORMAT ) ;
124129 const updatedBeaconsLists = this . updateBeaconList ( { identifier, uuid, minor, major, time } , 'monitorExitList' ) ;
@@ -160,14 +165,22 @@ class BeaconsDemo extends Component {
160165 }
161166
162167 render ( ) {
163- const { bluetoothState, beaconsLists } = this . state ;
168+ const {
169+ bluetoothState,
170+ beaconsLists,
171+ message
172+ } = this . state ;
164173
165174 return (
166175 < View style = { styles . container } >
167176 < Text style = { styles . btleConnectionStatus } >
168177 Bluetooth connection status: { bluetoothState ? bluetoothState : 'NA' }
169178 </ Text >
170179
180+ < Text >
181+ { message }
182+ </ Text >
183+
171184 < View style = { styles . justFlex } >
172185 < ListView
173186 dataSource = { beaconsLists }
0 commit comments