خرید بک لینک

Vote count: 0

Here is the example:

Student[] students = ...;
Subscriber<Course> subscriber = new Subscriber<Course>() {
    @Override
    public void onNext(Course course) {
        Log.d(tag, course.getName());
    }
    ...
};
Observable.from(students)
    .flatMap(new Func1<Student, Observable<Course>>() {
        @Override
        public Observable<Course> call(Student student) {
            retu Observable.from(student.getCourses());
        }
    })
    .subscribe(subscriber);

It's easy to observe courses, but what if I want to print out the pair of student-course? Is that necessary to change Observable<Course> to Observable<Pair<Student, Course>>? This method could be very tedious, because we'll have to use the Pairs all the way transforming the observable.

Is that any other good way we can refer to the original item based on the transformed one?

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: جمعه 10 ارديبهشت 1395 ساعت: 11:43

صفحه بندی