0.1.0 • Published 2 years ago

mocc-count-down v0.1.0

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

mocc-count-down

/**
 * 区间倒计时
 */
export declare class CountDown {
    /** 结束时间 */
    private endTime;
    /** 开始时间 */
    private startTime;
    /** 定时器 */
    private timer;
    /** 当前状态 */
    private status;
    /** 选项配置 */
    private options;
    /** 订阅者 */
    private depList;
    /**
     *
     * @param options 选项配置
     * @returns 当前实例
     */
    constructor(options: CountDownOptions);
    /**
     * 开始倒计时
     * @returns 当前实例
     */
    start(): this | undefined;
    /**
     * 更新定时器
     * @param options 选项配置
     * @param isFullUpdate 是否全量更新 而非合并更新
     * @returns 当前实例
     */
    update(options: CountDownOptions, isFullUpdate?: boolean): this;
    /**
     * 暂停
     * @returns 当前实例
     */
    pause(): this;
    /**
     * 获取当前状态
     * @return status
     */
    getStatus(): CountDownStatus;
    /**
     * 添加订阅者
     * @param cb 订阅者回调
     * @returns 当前实例
     */
    addListener(eventName: string, cb: CountDownCb): this;
    /**
     * 移除订阅者
     */
    removeListener(eventName: string): void;
    /**
     * 清除倒计时及所有数据
     */
    destory(): void;
    /**
     * 倒计时循环
     */
    private doCountDown;
    /**
     * 清除定时器
     */
    private clearTimer;
}
/**
 * 倒计时控制中心
 */
export declare class CountDownControler {
    static instance: CountDownControler;
    private countDownInstances;
    /**
     * 获取当前实例 - 单例模式
     * @returns 当前实例
     */
    static getInstance(): CountDownControler;
    /**
     * 创建定时器中控台
     * @param sessions 场次
     * @param options CountDown 选项配置
     * @returns 对应场次的 CountDown 实例
     */
    create(sessions: string | number, options: CountDownOptions): CountDown;
    /**
     * 获取对应场次的 CountDown 实例
     * @param sessions 场次
     * @param options CountDown 选项配置
     * @returns 对应场次的 CountDown 实例
     */
    private getCountDownCase;
    /**
     * 代理拦截 CountDown 实例
     * @param countDownCase CountDown 实例
     * @param props 需要使用的参数
     * @returns 处理后的 CountDown 实例
     */
    private proxyCountDownCase;
}