Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
List<String> gpsInString = Arrays.asList("GPS_1","GPS_2","GPS_3","GPS_4","GPS_5","GPS_6","GPS_7","GPS_8","GPS_9");
Observable.from(gpsInString).map(new Func1<String, Integer>() {
public Integer call(String s) {
int coordinate = Character.getNumericValue(s.charAt(4));
System.out.println("Converted "+s+" to "+coordinate);
return coordinate;
}).flatMap(new Func1<Integer, Observable<Hotel>>() {
//Example of flatmap, we have a list of coordinates now, but actually we want a list of locations close
public Observable<Hotel> call(Integer coordinate) {
System.out.println("Fetching hotel for "+ coordinate);
try {
} catch (InterruptedException e) {
return Observable.just(new Hotel());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.