Skip to content

Instantly share code, notes, and snippets.

@caponetto
Last active September 11, 2020 16:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save caponetto/9e4be8dfadc593e604d1fd468494a75f to your computer and use it in GitHub Desktop.
Save caponetto/9e4be8dfadc593e604d1fd468494a75f to your computer and use it in GitHub Desktop.
Backend sample service: Calling and handling the service response in the editor
SampleServiceWrapper.get().hello("Guilherme", 5000).then((CapabilityResponse<String> response) -> {
// Sample - capability not available can be handled like this.
if (CapabilityResponseStatus.withName(response.getStatus()) == CapabilityResponseStatus.NOT_AVAILABLE) {
DomGlobal.console.info(response.getMessage());
}
// Sample - response completed can be handled like this.
if (CapabilityResponseStatus.withName(response.getStatus()) == CapabilityResponseStatus.OK) {
DomGlobal.console.info(response.getBody());
}
return null;
}).catch_(error -> {
DomGlobal.console.error("Error caught: " + error);
return null;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment