mirror of
https://git.unlock-music.dev/um/um-react.git
synced 2024-11-24 01:22:17 +00:00
chore: type updates
This commit is contained in:
parent
cf3324e833
commit
3c0a9433dd
@ -27,7 +27,7 @@ export abstract class ConcurrentQueue<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async processQueue() {
|
private async processQueue() {
|
||||||
while (true) {
|
while (this.items.length > 0) {
|
||||||
const item = this.items.pop();
|
const item = this.items.pop();
|
||||||
if (item === undefined) {
|
if (item === undefined) {
|
||||||
break;
|
break;
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
import { nanoid } from 'nanoid';
|
import { nanoid } from 'nanoid';
|
||||||
|
|
||||||
export class WorkerClientBus {
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
|
|
||||||
|
export class WorkerClientBus<T = string> {
|
||||||
private idPromiseMap = new Map<string, [(data: any) => void, (error: Error) => void]>();
|
private idPromiseMap = new Map<string, [(data: any) => void, (error: Error) => void]>();
|
||||||
|
|
||||||
constructor(private worker: Worker) {
|
constructor(private worker: Worker) {
|
||||||
@ -22,7 +24,7 @@ export class WorkerClientBus {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async request<R = any, P = any>(actionName: string, payload: P): Promise<R> {
|
async request<R = any, P = any>(actionName: T, payload: P): Promise<R> {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const id = nanoid();
|
const id = nanoid();
|
||||||
this.idPromiseMap.set(id, [resolve, reject]);
|
this.idPromiseMap.set(id, [resolve, reject]);
|
||||||
|
Loading…
Reference in New Issue
Block a user