When I use sqlbrite, I can't use the rxjava function toList() after using groupBy(). Here is my code:
QueryObservable query = jetAnywhereDB.createQuery(Item.TABLE, "SELECT * FROM testTable");
query.flatMap(q -> {
return q.asRows(Item.MAPPER);
}).
groupBy(item -> {
return Character.toUpperCase(item.name.charAt(0));
}).
subscribe(groupedObservable -> {
groupedObservable.subscribe(item -> {
Log.d("test", groupedObservable.getKey() + ": " + item.name);
});
});
This works fine and logs all the items as they get emitted, but if I change it to
groupedObservable.toList().subscribe(items -> {
Log.d("test", groupedObservable.getKey() + ": " + items);
});
Am I not using toList() correctly? Could this be because the sqlbrite stream doesn't end so rxjava is waiting for more items to emit before completing the toList()?