{"action":"closed","issue":{"url":"https://api.github.com/repos/Polidea/RxBluetoothKit/issues/13","repository_url":"https://api.github.com/repos/Polidea/RxBluetoothKit","labels_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/issues/13/labels{/name}","comments_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/issues/13/comments","events_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/issues/13/events","html_url":"https://github.com/Polidea/RxBluetoothKit/issues/13","id":149568116,"number":13,"title":"Setting up notification on characteristic - possible race condition. ","user":{"login":"Kacper20","id":6010341,"avatar_url":"https://avatars.githubusercontent.com/u/6010341?v=3","gravatar_id":"","url":"https://api.github.com/users/Kacper20","html_url":"https://github.com/Kacper20","followers_url":"https://api.github.com/users/Kacper20/followers","following_url":"https://api.github.com/users/Kacper20/following{/other_user}","gists_url":"https://api.github.com/users/Kacper20/gists{/gist_id}","starred_url":"https://api.github.com/users/Kacper20/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kacper20/subscriptions","organizations_url":"https://api.github.com/users/Kacper20/orgs","repos_url":"https://api.github.com/users/Kacper20/repos","events_url":"https://api.github.com/users/Kacper20/events{/privacy}","received_events_url":"https://api.github.com/users/Kacper20/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Polidea/RxBluetoothKit/labels/bug","name":"bug","color":"ee0701"},{"url":"https://api.github.com/repos/Polidea/RxBluetoothKit/labels/question","name":"question","color":"cc317c"}],"state":"closed","locked":false,"assignee":{"login":"literator","id":242131,"avatar_url":"https://avatars.githubusercontent.com/u/242131?v=3","gravatar_id":"","url":"https://api.github.com/users/literator","html_url":"https://github.com/literator","followers_url":"https://api.github.com/users/literator/followers","following_url":"https://api.github.com/users/literator/following{/other_user}","gists_url":"https://api.github.com/users/literator/gists{/gist_id}","starred_url":"https://api.github.com/users/literator/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/literator/subscriptions","organizations_url":"https://api.github.com/users/literator/orgs","repos_url":"https://api.github.com/users/literator/repos","events_url":"https://api.github.com/users/literator/events{/privacy}","received_events_url":"https://api.github.com/users/literator/received_events","type":"User","site_admin":false},"milestone":null,"comments":2,"created_at":"2016-04-19T20:01:01Z","updated_at":"2016-04-21T12:45:13Z","closed_at":"2016-04-21T12:45:13Z","body":"Hi,\r\n\r\nSo basically: when we're setting up notification on characteristic that's proper way to do it(without use of convenience functions):\r\n```swift\r\ncharacteristic.setNotifyValue(true)\r\n    .flatMap { $0.monitorValueUpdate() }\r\n    .subscribeNext {\r\n        let newValue = $0.value\r\n    }\r\n```\r\nSo, first notification set is called, and after that .Next with characteristic that notification status was updated is emitted. Monitor on updates is called after that. The result is that in between of these two calls update event could happen and it'll be lost.\r\n\r\nPossible way to prevent this behavior is to do it like this:\r\n```swift\r\nObservable.of(characteristic.setNotifyValue(true).ignoreElements(), characteristic.monitorValueUpdate()).merge()\r\n.subscribeNext {\r\n//Read value\r\n}\r\n```\r\nBut i'm worried it's too verbose to user.\r\nSo maybe we should leave it like it is(so basic two functionalities) and add to this function like `setupNotificationAndMonitorUpdates`, that'll work for setting notification in state ON.\r\nWe could implement this like i showed in second snippet.\r\nWhat do you think?"}}