- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
更新:我刚刚检查了他们的示例项目,它是相同的。因此,这可能是一个错误,或者这是预期的行为。
我正在使用 RxBluetoothKit,无法解决以下问题。我有这个包装函数来编写一个特征(我试图用 concat 来编写其中的许多特征,它工作得很好):
func writeCharacteristicData(for peripheral: Peripheral, characteristicIdentifier: CharacteristicIdentifier, value: Data?) -> Observable<Characteristic> {
guard let value = value else {
return Observable.error(BTError.noDataProvided(description: "Missing value for: \(characteristicIdentifier)"))
}
return peripheral
.connect()
.flatMap { $0.writeValue(value,
for: characteristicIdentifier,
type: .withResponse) }
}
根据 RxBluetoothKit 文档 .flatMap { $0.writeValue }
是编写特征的最简单方法之一。实际上,它与 readValue
配合得很好。即使这样writeValue
,写入成功,如果我之后用 readValue 读回它,则 characteristic.value
可以在 oNext:
.
我的问题是这个函数返回 Observable<Characteristic>
我的假设是它会给我返回书面值(value)。但事实并非如此,或者至少对我来说不起作用。它给了我以前的值或零,到目前为止我无法弄清楚发出的 Observable<Characteristic>
的逻辑是什么。 。如果我能拿回书面值(value),那就太好了。我做错了什么?
我什至尝试了更长的方法,github 上提到了这个:
characteristic.writeValue(data, type: .withResponse)
.subscribe { event in
//respond to errors / successful read
}
发出的特征(在 onNext:
回调中)不是我写入设备的特征。它是前一项或零。有趣的是,如果我尝试读回它,然后再写,characteristic.value 将是我用 $0.readValue
读取的值。 。但如果我重新编译,写一个全新的,它仍然是我以前读过的。就像 RxBluetoothKit 缓存了一个值,或者我什么都不知道。
这可能是 ble 设备的问题吗?也许这是一个线程问题或类似的问题?
我真的很感激任何建议或提示。
谢谢
丹尼尔
最佳答案
很抱歉没有回复,我刚刚注意到这一点。您的问题还出现吗?如果是这样 - 请在我们的 Github 上写一个问题。它与核心蓝牙本身的工作方式有关,我们也许应该改进我们的文档,因此最好将其作为一个问题。您应该做的是再次读取该值 - 然后它将显示正确的值。
关于swift - 特性的 flatMap writeValue 不返回 Observable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44371609/
我有一个对象Foo,其中包含Bar列表。这些类的描述如下: class Foo { String name; List bars = new ArrayList(); Foo(
根据 Mozilla 开发者网站: flatMap() 方法首先使用映射函数映射每个元素,然后将结果展平到一个新数组中。它与 map 后跟深度为 1 的 flat 相同,但 flatMap 通常非常有
我对无法找到该问题的现有问题感到非常惊讶。这是为什么,鉴于: val p: Int => Option[Int] = Some(_) List(1, 2, 3).flatMap(p) 我得到: :14
关闭。此题需要details or clarity 。目前不接受答案。 想要改进这个问题吗?通过 editing this post 添加详细信息并澄清问题. 已关闭 5 年前。 Improve th
我想知道两种平面映射情况之间是否存在显着差异。 案例 1: someCollection .stream() .map(CollectionElement::getAnotherCol
以下是flatMap的定义取自 scala.util.Success。 final case class Success[+T](value: T) extends Try[T] { def fl
我正在寻找一个函数来展平列表数组。首先,我在 RDD 系统上使用 Apach Spark 函数 flatMap 实现了我的解决方案,但我想在本地执行此操作。但是,我无法找到 的等价物 samples
我想知道是否存在忽略 flatMap 中的结果的函数(在 scala 或 cat 中) .例如。 Some("ignore this").ignoreArgumentFlatMap(Some("res
我正在学习 Scala 并解决了 99 个 Scala 问题。对于以下练习: 展平嵌套列表结构。示例: scala> flatten(List(List(1, 1), 2, List(3, List(
当编译器进入无限循环时,是否有人遇到过使用此类 flatMap 链(或什至更长)的问题。 let what = Future.init { (promise) in promise(.succ
有没有更好的函数方式来写 flatMap ? def flatMap[A,B](list: List[A])(f: A => List[B]): List[B] = list.map(x =>
我试图从两个 中变出笛卡尔积潜在无限然后我通过 limit() 限制的流. 到目前为止,这(大约)是我的策略: @Test void flatMapIsLazy() { Stream.
为什么以下声明对 .map() 有效但不适用于 .flatMap() ? val tupled = input.map(x => (x*2, x*3)) //Compilation error:
我正在寻找可以同时映射和展平 Lists 和 Maybes 的代码。我在 this topic 中发现了这样一个 flatMap 函数: flatMap :: (t -> [a]) -> [t] ->
考虑在某些大小写匹配上编写的 flatMap。例如: list.flatMap( v => v match { case Cond1 => if(something) Some
我无法使用ListKOf平面映射T -> Option。 例如 listOf(1,2,3).k().flatMap { i -> if (i % 2 == 0) Some(i) else None
有人可以解释我如何在RxJava中通过flatMap运算符传递onComplete信号吗? 如果对flatMap运算符进行注释,则可以获取1到10的数字列表,这意味着toList将收到onComple
我正在做一个在线类(class)并误读了一个问题(这就是为什么我认为可以发布这个问题,因为答案与类(class)中的问题无关!)。 data class Trip( val drive
给定作为数据类的二维坐标列表 data class Point(val x: Int, val y:Int) val points: List 和 TornadoFX(Kotlin 中的 JavaFX
这个问题已经有答案了: What is the difference between .stream() and Stream.of? (5 个回答) 已关闭 3 年前。 我有以下代码: List p
我是一名优秀的程序员,十分优秀!