英文:
how to get data from android signalr invoke
问题
如何从调用方法中检索数组?调用方法可正常运行,但我找不到如何在Java客户端中从中获取数组。
HubConnection hubConnection;
hubConnection = HubConnectionBuilder.create(Constants.BASE_LOCAL_HUB_URL).withAccessTokenProvider(Single.defer(() -> {
// Your logic here.
return Single.just(token);
})).build();
hubConnection.invoke(UserViewModel[].class, "GetUsers");
英文:
How can can retrieve the array from invoke method? The invoke method works, but I couldn't find how I can get the array from it in Java client.
HubConnection hubConnection;
hubConnection = HubConnectionBuilder.create(Constants.BASE_LOCAL_HUB_URL).withAccessTokenProvider(Single.defer(() -> {
// Your logic here.
return Single.just(token);
})).build();
hubConnection.invoke(UserViewModel[].class, "GetUsers");
答案1
得分: 1
Invoke方法返回一个Single<T>
,其中T是您指定的类型(UserViewModel[]
)。
因此,您需要通过订阅该Single来使用返回值。https://www.tutorialspoint.com/rxjava/rxjava_single_observable.htm
测试其是否正常工作的最快方法是执行:
UserViewModel[] arr = hubConnection.invoke(UserViewModel[].class, "GetUsers").blockingGet();
英文:
Invoke returns a Single<T>
where T is the type you specified (UserViewModel[]
).
So you need to use the return value by subscribing to the Single. https://www.tutorialspoint.com/rxjava/rxjava_single_observable.htm
The quickest way to test it is working is to do:
UserViewModel[] arr = hubConnection.invoke(UserViewModel[].class, "GetUsers").blockingGet();
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论