5

I have a stream builder, and i want to access the previously emitted value from the stream. If one is familiar with distinct, they must know that distinct basically checks if previous and current value is the same. I want access to the previous value. To create my own custom condition.

I am using replay-subject from RxDart with a max capacity : 2. No whenever i add something to the sink of the stream using sink.add(data); all the instances of replay-subject are replaced by the new data. thus, i do not have access to the previous data, it just gets overridden. I am stuck need help in how to add data to the replay subject. if not using sink.add() method

GoPro
  • 642
  • 1
  • 10
  • 24
  • May be you are looking for ReplaySubject class – Saed Nabil Dec 07 '18 at 19:54
  • Yes, i am. However, whenever i try to add an event to replaySubject. It adds to the entire list. For example if i add "123" to a replaysubject with max capacity:2. then replaysubject.values will be ["1", "1"] and if i do sink.add(2), this changes the entire thing to ["2","2"]. I just want the replaysubject to hold ["1","2"] for me. – GoPro Dec 07 '18 at 20:37
  • I think you are recreating your replay subject every time you add an event to it could you please provide your code – Saed Nabil Dec 07 '18 at 21:12
  • I created https://github.com/ReactiveX/rxdart/issues/205 – Günter Zöchbauer Dec 08 '18 at 10:48

1 Answers1

1

Per GitHub ticket filed, this buggy behavior should be fixed by rxdart 0.20.0 release.

Also, as mentioned in this thread, I believed the issue could be answered by #210 and should be available now.

This fix should properly handle buffer on count and window on count, when using the startBufferEvery parameter.

This is a breaking change:

  • startBufferEvery should now work correctly
  • when the parent Stream completes, we no longer add the remainder buffer as a final event: i.e. if the buffer is set to group by 3 events, and the parent Stream outputs 1, 2, 3, 4, then the only event on buffer(3) would be [1, 2, 3]. Before, we would also dispatch [4] as the remainder onDone.
MαπμQμαπkγVπ.0
  • 5,887
  • 1
  • 27
  • 65