ProtoViewLogic: isProcessing()

メッセージが処理中かを判別します。

構文

protoViewLogic.isProcessing(message) => boolean

引数

  • message: object

    送信するメッセージです。 このオブジェクトは以下のプロパティを持ちます:

    • id: string | null

      メッセージの識別子です。

    • code: string | null

      メッセージの追加の識別子です。

返値: boolean

メッセージが処理中かどうかを示す boolean です。 true の場合、idcode が同一のメッセージを処理中です。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 のインスタンスで idcode が一致するメッセージが処理中であれば true を返します。 処理中でなければ false を返します。