android - What is the way for having a list through rxjava? -


i bit new rxjava. trying have list on rxjava iterating on result. tried operator tolist() not work out. following working fine. however, wonder if there better way reactive perspective?

db.loaddata().map(new func1<realmresults<data>, list<string>>() {         @override         public list<string> call(realmresults<data> datas) {             list<string> companies = new arraylist<string>(5);             (company company : datas.get(0).getcompanies()) {                 companies.add(company.getname());             }             return companies;         }     }).subscribe(new action1<list<string>>() {         @override         public void call(list<string> strings) {             showcompanydialog(strings);         }     }); 

so (pseudocode don't know object types have):

db.loaddata()     .map(new func1<realmresults<data>, list<company>>() ) {         public list<company> call(realmresults<data> datas) {             return datas.get(0).getcompanies();         }      }).flatmap(new func1<list<company>, observable<company>>() {         @override         public observable<company> call(list<company> companies) {             return observable.from(companies);         }     }.map(new func1<company, string>() {         public stringcall(company company) {             return company.getname();         }     }).tolist(); 

that means:

  1. get results database
  2. get companies realmresult
  3. split companies
  4. get name of each company
  5. concatenate results list<string>

Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -