我有一个流构建器,我想从流中访问之前发出的值。如果熟悉 distinct,他们一定知道 distinct 主要检查先前值和当前值是否相同。我想访问以前的值。创建我自己的自定义条件。
我正在使用 RxDart 的 replay-subject,最大容量:2。每当我使用 sink.add(data) 向流的接收器添加内容时,都不会; replay-subject 的所有实例都被新数据替换。因此,我无法访问以前的数据,它只是被覆盖了。我在如何将数据添加到重播主题方面需要帮助。如果不使用 sink.add() 方法
最佳答案
根据 Github ticket filed ,这种 buggy 行为should be fixed通过 rxdart 0.20.0 release .
此外,如 this thread 中所述, 我相信这个问题可以通过 #210 来回答并且现在应该可用。
This fix should properly handle
buffer
oncount
andwindow
oncount
, when using thestartBufferEvery
parameter.This is a breaking change:
- startBufferEvery should now work correctly
- when the parent
Stream
completes, we no longer add the remainderbuffer
as a finalevent
: i.e. if thebuffer
is set to group by 3 events, and the parentStream
outputs1, 2, 3, 4
, then the onlyevent
onbuffer(3)
would be[1, 2, 3]
. Before, we would also dispatch[4]
as the remainderonDone
.
关于dart - Flutter Streams,如何从流中访问之前发出的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53675041/