Add clear queue api (#171)
* Add clear queue api * Minor improvement * Update changelog --------- Co-authored-by: Foti Dim <foti@navideck.com>
This commit is contained in:
@@ -414,6 +414,12 @@ class UniversalBle {
|
||||
);
|
||||
}
|
||||
|
||||
/// Clear a queue.
|
||||
/// Use [BleCommandQueue.globalQueueId] to clear the global queue.
|
||||
/// To clear the queue of a specific device, use `deviceId` as [id].
|
||||
/// If no [id] is provided, all queues will be cleared.
|
||||
static void clearQueue([String? id]) => _bleCommandQueue.clearQueue(id);
|
||||
|
||||
/// [receivesAdvertisements] returns true on web if the browser supports receiving advertisements from a certain `deviceId`.
|
||||
/// The rest of the platforms will always return true.
|
||||
/// If true, then you will be getting scanResult updates for this device.
|
||||
|
||||
@@ -51,4 +51,14 @@ class BleCommandQueue {
|
||||
_queueMap[id] = queue;
|
||||
return queue;
|
||||
}
|
||||
|
||||
void clearQueue(String? id) {
|
||||
if (id == null) {
|
||||
_queueMap.forEach((k, v) => v.dispose());
|
||||
_queueMap.clear();
|
||||
} else {
|
||||
_queueMap[id]?.dispose();
|
||||
_queueMap.remove(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user