ProtoViewLogic: isProcessing()
メッセージが処理中かを判別します。
構文
protoViewLogic.isProcessing(message) => boolean
引数
-
message:object送信するメッセージです。 このオブジェクトは以下のプロパティを持ちます:
-
id:string|nullメッセージの識別子です。
-
code:string|nullメッセージの追加の識別子です。
-
返値: boolean
メッセージが処理中かどうかを示す boolean です。
true の場合、id と code が同一のメッセージを処理中です。false の場合、同一のメッセージは処理中ではありません。
例
const process = new class Process extends ProtoViewLogic {
async messageHandler(message) {
if (message.id === "start") {
const msg = this.message("process", null, null);
this.post(msg);
console.log(this.isProcessing(msg));
// ==> メッセージを処理中なのでコンソールに true と表示される
}
}
}
process.post(process.message("start", null, null));
解説
引数 message が処理中かどうかを boolean で返します。
呼び出したProtoViewLogic のインスタンスで id と code が一致するメッセージが処理中であれば true を返します。
処理中でなければ false を返します。