You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am new to the Reactive framework and I have a question about your library. I want to save a ParseObject(1) that has several ParseObject(2)s attached to it through a relation. Each of these ParseObject(2)'s has a ParseFile attached. So I want to make sure that I create all of these objects in the right order. My approach was:
final ParseObject1 parseObject1 = new ParseObject1();
final ParseRelation<ParseObject> imagesRelation = parseObject1.getRelation("images");
Observable.just(1)
.subscribeOn(Schedulers.io())
.flatMap(new Function<Object, ObservableSource<ParseFile>>() {
@Override
public ObservableSource<ParseFile> apply(Object aVoid) throws Exception {
bytes[] bytes = (..);
ParseFile file = new ParseFile("1.jpg", bytes);
return ParseObservable.save(file);
}
}).flatMap(new Function<ParseFile, ObservableSource<ParseObject2>>() {
@Override
public ObservableSource<ParseObject2> apply(ParseFile file) throws Exception {
ParseObject2 parseObject2 = new ParseObject2();
parseObject2.put("file", file);
return ParseObservable.save(parseObject2);
}
})
.flatMap(new Function<ParseObject2, ObservableSource<ParseFile>>() {
@Override
public ObservableSource<ParseFile> apply(ParseObject2 parseObject2) throws Exception {
imagesRelation.add(parseObject2);
bytes[] bytes = (..);
ParseFile file = new ParseFile("2.jpg", bytes);
return ParseObservable.save(file);
}
})
.flatMap(new Function<ParseFile, ObservableSource<ParseObject2>>() {
@Override
public ObservableSource<ParseObject2> apply(ParseFile parseFile) throws Exception {
ParseObject2 parseObject2 = new ParseObject2();
parseObject2.put("file", parseFile);
return ParseObservable.save(parseObject2);
}
})
.flatMap(new Function<ParseObject2, ObservableSource<ParseObject1>>() {
@Override
public ObservableSource<ParseObject1> apply(ParseObject2 parseObject2) throws Exception {
imagesRelation.add(parseObject2);
parseObject1.put("description", "This is an object");
return ParseObservable.save(parseObject1);
}
})
.subscribe(new Observer<Object>() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onNext(Object value) {
}
@Override
public void onError(Throwable e) {
}
@Override
public void onComplete() {
Toast.makeText(getContext(), "added!", Toast.LENGTH_SHORT).show();
}
});
But only the first .flatMap is executed. I want the whole chain to be executed. Any idea how I can transform my code?
The text was updated successfully, but these errors were encountered:
Hi,
I am new to the Reactive framework and I have a question about your library. I want to save a
ParseObject(1)
that has severalParseObject(2)
s attached to it through a relation. Each of theseParseObject(2)
's has aParseFile
attached. So I want to make sure that I create all of these objects in the right order. My approach was:But only the first .flatMap is executed. I want the whole chain to be executed. Any idea how I can transform my code?
The text was updated successfully, but these errors were encountered: