lastValueStream property

Stream<List<int>> lastValueStream

this stream emits values:

  • anytime read() is called
  • anytime write() is called
  • and when first listened to, it re-emits the last value for convenience

Implementation

Stream<List<int>> get lastValueStream => FlutterBluePlus._methodStream.stream
    .where((m) => m.method == "OnDescriptorRead" || m.method == "OnDescriptorWritten")
    .map((m) => m.arguments)
    .map((args) => BmDescriptorData.fromMap(args))
    .where((p) => p.remoteId == remoteId)
    .where((p) => p.characteristicUuid == characteristicUuid)
    .where((p) => p.serviceUuid == serviceUuid)
    .where((p) => p.descriptorUuid == descriptorUuid)
    .where((p) => p.success == true)
    .map((p) => p.value)
    .newStreamWithInitialValue(lastValue);