E
E
enchikiben2020-03-27 12:34:01
Dart
enchikiben, 2020-03-27 12:34:01

Event handling in flutter?

Good afternoon! Help with advice, I use RxDart and BLoC.
In bloc, my data is processed in a loop and events are sent in it:

final _controller = BehaviorSubject();

for(var item in items){
var data = [];

/* тут код */

_controller.add(State._status(SearchStatus.inProgress));
_controller.add(State._data(data));
}


but for some reason only the last event always comes to the StreamBuilder ... I thought that I needed to specify another subscription class pub.dev/documentation/rxdart/latest/rx_subjects/rx_subjects-library.html but it didn’t help.

How to be?

Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrew Nodermann, 2020-04-09
@Lucian

The docs say: A special StreamController that captures the latest item that has been added to the controller , and emits that as the first item to any new listener.
Use ReplaySubject instead of BehaviorSubject

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question