# 引入

import { Scheduler  } from 't-comm';

// or

import { Scheduler } from 't-comm/lib/scheduler/index';

# Scheduler

参数

# new Scheduler([maxConcurrency])

异步任务调度器,同一时间只能执行 n 个任务

Param Type Default Description
[maxConcurrency] number 2

最多同时执行的任务数目,默认为 2

Example

let scheduler;

export async function login({
  userId,
  userSig,
  tim,
}: {
  userId: string;
  userSig: string;
  tim: IChatSDK;
}) {
  if (!scheduler) {
    scheduler = new Scheduler(1);
  }

  return await scheduler.add(innerLogin.bind(null, {
    userId,
    userSig,
    tim,
  }));
}
Last Updated: 2024/10/11 07:54:02