Interface PendingOperation
비동기 호출의 연산에 대응되는 객체입니다.
| Constructor Attributes | Constructor Name and Description |
|---|---|
|
비동기 호출의 연산에 대응되는 객체입니다. |
Method Summary
Interface Detail
PendingOperation()
비동기 호출의 연산에 대응되는 객체입니다. 이 인터페이스는 비동기 호출을 취소할 수 있도록 하기 위해 비동기 호출에 의해 반환됩니다.
var pendingOp = null;
// SMS sending example
var msg = deviceapis.messaging.createMessage(Messaging.MESSAGE_TYPE_SMS);
msg.body = "I will arrive in 10 minutes";
msg.destinationAddress[0] = "+34666666666";
// Define the success callback
function messageSent() {
alert("The SMS has been sent");
pendingOp = null;
}
// Define the error callback
function messageFailed(error) {
alert("The SMS could not be sent " + error.message);
pendingOp = null;
}
// To be executed if, for instance, the user presses a cancel button in the user interface
function cancel() {
if (pendingOp != null) {
if (pendingOp.cancel()) {
alert("The message sending has been canceled");
} else {
alert("The operation cannot be canceled");
}
} else {
alert("The operation cannot be canceled");
}
}
pendingOp = deviceapis.messaging.send(msg, messageSent, messageFailed);
Method Detail
-
{boolean} cancel()
비동기적으로 수행 중인 연산을 취소합니다. 이 호출은 실패 없이 항상 성공합니다. 비동기 호출이 취소된 경우는 물론 비동기 호출이 이미 종료되어 취소할 수 없는 경우에도 실패하지 않습니다.
- Returns:
- {boolean}
비동기 작업이 이미 종료되었거나 기술적 제약으로 비동기 작업을 취소시킬 수 없는 경우 false를 반환합니다. 이 경우 비동기 호출의 결과가 관련된 콜백 함수로 전달되어 호출됩니다. 비동기 작업을 취소시킨 경우 true를 반환합니다. 이 경우 비동기 호출과 관련된 콜백 함수가 호출되지 않습니다.
