0
Consider the following code snippet.
ReplaySubject<List<Object>> subject = ReplaySubject.create();
subject.subscribe(view::mostraListaObjetos);
subject.onNext(getListOnline());
//logo apos essa linha o metodo view.mostrarListaObjetos(lista)
//deveria ser chamado ou estou errado?
The problem is that no matter how many times I call onNext() the Observer never gets anything. someone has an idea of why?
Edited had summarized the code, but I found that this way works well, but when I use the operators flatMapInterable
and toList
is that I get nothing until the subject.onComplete()
is called!
Example of detailed code.
ReplaySubject<List<Object>> subject = ReplaySubject.create();
subject.flatMapIterable(object -> {
Log.d(TAG, "flatMapIterable: it is called");
return object;
}).doOnEach(objNotification -> Log.d(TAG, "doOnEach: it is called"))
.toList()
.subscribe(obj -> Log.d(TAG, "subscribe: it is only called after subscribe.onComplete()"));
subject.onNext(getListOfObjects());
Log.d(TAG, "onComplete:");
subject.onComplete();
Output from the logcat:
07-04 23:20:38.258 10770-10770/app.package D/TAG: flatMapIterable: it is called
07-04 23:20:38.259 10770-10770/app.package D/TAG: doOnEach: it is called
07-04 23:20:38.259 10770-10770/app.package D/TAG: onComplete:
07-04 23:20:38.260 10770-10770/app.package D/TAG: doOnEach: it is called
07-04 23:20:38.260 10770-10770/app.package D/TAG: it is only called after subscribe.onComplete()
In the doc say yes
– Marcus Duarte