我对 rxJava 相当陌生。在我的 api 响应中,我获得了有关总页数和当前页码的信息,例如:
"pages": 22,
"page": 1,
Run Code Online (Sandbox Code Playgroud)
我正在使用 Retrofit 在数据层进行 api 调用,我的 api 服务如下:
@GET("/story")
Observable <StoryCollectionEntity> storyCollection(
@Query("feed_ids") String feed_items,
@Query("page") int page);
Run Code Online (Sandbox Code Playgroud)
然后:
public Observable<StoryCollectionEntity> storyCollection() {
return mUserApi.storyCollection(items,page);
}
Run Code Online (Sandbox Code Playgroud)
我在域层进行了这样的订阅:
public void execute(Subscriber UseCaseSubscriber) {
this.subscription = this.buildUseCaseObservable()
.subscribeOn(Schedulers.from(threadExecutor))
.observeOn(postExecutionThread.getScheduler())
.subscribe(UseCaseSubscriber);
}
@Override public Observable buildUseCaseObservable() {
return this.userRepository.stories();
}
Run Code Online (Sandbox Code Playgroud)
我正在弄清楚如何通过发出下一页的结果让这个观察者对 recyclerView 滚动事件做出反应。即第 2 页到第二个滚动事件和第 3 页在第 3 次滚动...等
我正在尝试在发布请求负载中传递数组。
url = http://IP:PortNo/index.php/v1/login
Run Code Online (Sandbox Code Playgroud)
有效负载:
data={ "terminal_id": "terminal_id", "api_login": "api_login", "api_key": "api_key", "merchant_code": "merchant_code" }
Run Code Online (Sandbox Code Playgroud)
我所做的是:
$data = ['terminal_id' => $this->terminal_id , 'api_login' => $this->api_login,
'api_key' => $this->api_key , 'merchant_code' => $this->merchant_code];
$response = $this->client->post($url, array('data' => $data));
Run Code Online (Sandbox Code Playgroud)
但我得到的回应是:
“未找到请求数据”
这意味着我的数据有效负载格式不正确。任何想法?