Skip to content

Instantly share code, notes, and snippets.

@michaelzengke
Created October 20, 2016 18:26
Show Gist options
  • Save michaelzengke/f759f517964279de50108002aeb4a386 to your computer and use it in GitHub Desktop.
Save michaelzengke/f759f517964279de50108002aeb4a386 to your computer and use it in GitHub Desktop.
public interface MyStuffEntity {
EntityType getEntityType();
}
public class MyStuff {
MyStuffEntity savedJobPostings;
MyStuffEntity appliedJobPostings;
}
Observable<MyStuff> myStuffRepository = Observable
.merge(savedJobPostingRepository, appliedJobPostingRepository)
.reduce(new MyStuff(), (accumulated, item) -> {
switch (item.getEntityType()) {
case SavedJobs:
accumulated.savedJobPostings = item;
break;
case AppliedJobs:
accumulated.appliedJobPostings = item;
break;
}
return accumulated;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment