react-native-bluetooth-state
react-native-bluetooth-state copied to clipboard
BluetoothState.unsubscribe()
Hey frostney,
is there a way to unsubscribe BluetoothState? I do BluetoothState.subscribe()
in my componentWillMount()
and I want to BluetoothState.unsubscribe()
in my comonentWillUnmount()
,
Best regards, albo
That's not available yet through the API (yet), but you can do DeviceEventEmitter.removeListener('centralManagerDidUpdateState');
This may not be what you want though, since that call would get rid of all subscribers.
DeviceEventEmitter.removeListener
is not a function yet. Not working for me. I think it's because I still use react native v 0.24.1
@albo1337 I'm sorry, I mis-remembered the method name. It's DeviceEventEmitter.removeAllListeners('centralManagerDidUpdateState');