-
Notifications
You must be signed in to change notification settings - Fork 369
7. Monitoring characteristic value change
paweljaneczek edited this page Jul 2, 2018
·
3 revisions
Notifying characteristic value changes? Nothing easier.
After subscribing observable returned by this method, you will get proper message every single time:
let disposable = characteristic.observeValueUpdateAndSetNotification()
.subscribe(onNext: {
let newValue = $0.value
})
If you are not interested anymore in updates, just unsubscribe:
disposable.dispose()
Note: You can do multiple observeValueUpdateAndSetNotification
on the same characteristic from different parts in your code. What library does is setting notify to true only at first subscription and unsetting it on last dispose.