Switch from defer to Promise.withResolvers (#29078)

* Switch from defer to PromiseWithResolvers

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Add modernizr check

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Iterate

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

---------

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski
2025-05-08 11:03:43 +01:00
committed by GitHub
parent 0f783ede5e
commit a3f5d207de
34 changed files with 61 additions and 89 deletions
@@ -6,8 +6,6 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Com
Please see LICENSE files in the repository root for full details.
*/
import { defer } from "matrix-js-sdk/src/utils";
import defaultDispatcher from "../../../src/dispatcher/dispatcher";
import { Action } from "../../../src/dispatcher/actions";
import { AsyncActionPayload } from "../../../src/dispatcher/payloads";
@@ -20,8 +18,8 @@ describe("MatrixDispatcher", () => {
});
it("should execute callbacks in registered order", async () => {
const deferred1 = defer<number>();
const deferred2 = defer<number>();
const deferred1 = Promise.withResolvers<number>();
const deferred2 = Promise.withResolvers<number>();
const fn1 = jest.fn(() => deferred1.resolve(1));
const fn2 = jest.fn(() => deferred2.resolve(2));
@@ -36,8 +34,8 @@ describe("MatrixDispatcher", () => {
});
it("should skip the queue for the given callback", async () => {
const deferred1 = defer<number>();
const deferred2 = defer<number>();
const deferred1 = Promise.withResolvers<number>();
const deferred2 = Promise.withResolvers<number>();
const fn1 = jest.fn(() => deferred1.resolve(1));
const fn2 = jest.fn(() => deferred2.resolve(2));