Skip to content

Commit

Permalink
Merge pull request #1145 from vhakulinen/bugfix/ios-multiple-readers
Browse files Browse the repository at this point in the history
ios: correctly insert callbacks
  • Loading branch information
marcosinigaglia authored Dec 22, 2023
2 parents 1c5c261 + 994c711 commit 44ab286
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions ios/BleManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,9 @@ class BleManager: RCTEventEmitter, CBCentralManagerDelegate, CBPeripheralDelegat
// Helper method to insert callback in different queues
func insertCallback(_ callback: @escaping RCTResponseSenderBlock, intoDictionary dictionary: inout Dictionary<String, [RCTResponseSenderBlock]>, withKey key: String) {
serialQueue.sync {
if var peripheralCallbacks = dictionary[key] {
peripheralCallbacks.append(callback)
} else {
var peripheralCallbacks = [RCTResponseSenderBlock]()
peripheralCallbacks.append(callback)
dictionary[key] = peripheralCallbacks
}

var peripheralCallbacks = dictionary[key] ?? [RCTResponseSenderBlock]()
peripheralCallbacks.append(callback)
dictionary[key] = peripheralCallbacks
}
}

Expand Down

0 comments on commit 44ab286

Please sign in to comment.