@@ -135,7 +135,8 @@ Because all of wanted services are discovered at once, method returns `Observabl
135
135
Here's how it works in RxBluetoothKit:
136
136
``` swift
137
137
peripheral.connect ()
138
- .flatMap { Observable.from ($0 .discoverServices ([serviceId])) }
138
+ .flatMap { $0 .discoverServices ([serviceId]) }
139
+ .flatMap { Observable.from ($0 ) }
139
140
.subscribeNext { service in
140
141
print (" Discovered service: \( service ) " )
141
142
}
@@ -147,8 +148,10 @@ This time API's returning `Observable<[Characteristic]>` and to process one
147
148
characteristic at a time, you need to once again use ` Observable.from() `
148
149
``` swift
149
150
peripheral.connect ()
150
- .flatMap { Observable.from ($0 .discoverServices ([serviceId])) }
151
- .flatMap { Observable.from ($0 .discoverCharacteristics ([characteristicId])}
151
+ .flatMap { $0 .discoverServices ([serviceId]) }
152
+ .flatMap { Observable.from ($0 ) }
153
+ .flatMap { $0 .discoverCharacteristics ([characteristicId])}
154
+ .flatMap { Observable.from ($0 ) }
152
155
.subscribeNext { characteristic in
153
156
print (" Discovered characteristic: \( characteristic ) " )
154
157
}
@@ -160,8 +163,10 @@ In order to do that, you should use `readValue()` function defined on `Character
160
163
We decided to return ` Characteristic ` instead of ` NSData ` due to one purpose - to allow you chain operations on characteristic in easy way.
161
164
``` swift
162
165
peripheral.connect ()
163
- .flatMap { Observable.from ($0 .discoverServices ([serviceId])) }
164
- .flatMap { Observable.from ($0 .discoverCharacteristics ([characteristicId])}
166
+ .flatMap { $0 .discoverServices ([serviceId]) }
167
+ .flatMap { Observable.from ($0 ) }
168
+ .flatMap { $0 .discoverCharacteristics ([characteristicId])}
169
+ .flatMap { Observable.from ($0 ) }
165
170
.flatMap { $0 .readValue () }
166
171
.subscribeNext {
167
172
let data = $0 .value
0 commit comments