我正在尝试使用retrofit rxjava来进行嵌套的api调用.基本上我必须构建一个Library对象列表.每个Library对象都有一个Authors列表,每个Author对象都有一个Books列表.这就是我的json的结构.
图书馆json –
{
title: "Library",items: [
{
title: "Library1"
image: "http://example.com/image/101/image_lib1.png"
url: "http://example.com/api/1"
},{
title:"Library2"
image: "http://example.com/image/101/image_lib2.png"
url: "http://example.com/api/2"
},{
title:"Library3"
image: "http://example.com/image/101/image_lib3.png"
url: "http://example.com/api/3"
}
]
}
和作者json-
{
title: "Authors",items: [
{
title: "J.K Rowling"
image: "http://example.com/image/101/image_author1.png"
url: "http://example.com/api/101"
},{
title:"Mark Twain"
image: "http://example.com/image/101/image_author2.png"
url: "http://example.com/api/201"
},{
title:"Charles Dickens"
image: "http://example.com/image/101/image_author3.png"
url: "http://example.com/api/301"
}
]
}
和书籍json-
{
description: Books,imageurl: "http://example.com/image/101/image_101.png",items: [
{
id: 101,title: "Oliver Twist ",description: "some description"
},{
id: 1011,title: "Hard times",description: "some more description."
}
}
]
}
我的api界面如下.
@GET("/api/")
ObservableFeedId}")
ObservableFeedId") String FeedId);
@GET("/api/{FeedId}")
ObservableFeedId") String FeedId);
Observable
我正在尝试构建一个可用于更新UI的Librarylist对象.我有点被困在这里.进行多次调用后,如何保存结果并将所有内容收集到库对象列表中?
最佳答案
Observable
注意.subscribe()调用.它们用于开始执行整个链.在订户到达之前,RxObservable不执行任何操作.