Skip to content

Sync Request

Orhan Obut edited this page Aug 9, 2015 · 1 revision

Wasp provides sync requests along with async. You may already handle background thread by yourself and want to use sync operation.

  • Define response object as a return type in your api, that will do the job
interface Service {
  User getUser();
}

Wasp automatically will use a sync operation when the return type is provided except Observable and WaspRequest.

When you call service.getUser(), this line will block the thread until the response is returned or timeout expires. Use try/catch block to handle exceptions.

Usage

User user = service.getUser(); 
Clone this wiki locally