timers#clearTimeout TypeScript Examples

The following examples show how to use timers#clearTimeout. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: update_lock.ts    From SpaceEye with MIT License 6 votes vote down vote up
/**
     * Release lock on the download pipeline.
     */
    public release(): void {
        clearTimeout(this.lockTimeout)
        if (this === UpdateLock.activeLock) {
            UpdateLock.activeLock = undefined
        }
    }
Example #2
Source File: venusRuntime.ts    From vscode-riscv-venus with MIT License 6 votes vote down vote up
/**
	 * Stop execution
	 */
	public stop() {
        simulator.driver.handleNotExitOver();
		clearTimeout(simulator.driver.timer);
		simulator.driver.timer = null;
		this.sendEvent('end');
	}
Example #3
Source File: venusRuntime.ts    From vscode-riscv-venus with MIT License 6 votes vote down vote up
/** Ends a long running code sequence*/
    private runEnd() {
        simulator.driver.handleNotExitOver();
		clearTimeout(simulator.driver.timer);

		simulator.driver.timer = null;
		this.updateMemory();
		if (simulator.driver.sim.isDone()) {
			this.sendEvent('end');
		} else if (simulator.driver.sim.atBreakpoint()) {
			this.sendEvent('stopOnBreakpoint');
		} else {
			this.sendEvent('stopOnStep');
		}
	}
Example #4
Source File: useLocalCacheState.ts    From yakit with GNU Affero General Public License v3.0 6 votes vote down vote up
// 关于获取函数还有点问题,暂不可用
export default function useLocalCacheState(keyword: string) {
    const [cache, setCache, getCache] = useGetState<string>()

    const time = useRef<any>(null)

    useEffect(() => {
        ipcRenderer
            .invoke("get-value", keyword)
            .then((res: any) => setCache(res))
            .catch(() => {})

        return () => {
            ipcRenderer.invoke("set-value", keyword, getCache())
        }
    }, [])

    const setLocalCache = (value?: string) => {
        if (time.current) {
            clearTimeout(time.current)
            time.current = null
        }
        time.current = setTimeout(() => {
            setCache(value)
            ipcRenderer.invoke("set-value", keyword, value)
        }, 1000)
    }

    const getLocalCache = () => {
        return getCache()
    }

    return [cache, {setLocalCache, getLocalCache}] as const
}
Example #5
Source File: action.ts    From actions-clever-cloud with MIT License 5 votes vote down vote up
export default async function run({
  token,
  secret,
  appID,
  alias,
  cleverCLI,
  timeout,
  extraEnv = {}
}: Arguments): Promise<void> {
  try {
    await checkForShallowCopy()

    core.debug(`Clever CLI path: ${cleverCLI}`)

    // Authenticate (this will only store the credentials at a known location)
    await exec(cleverCLI, ['login', '--token', token, '--secret', secret])

    // There is an issue when there is a .clever.json file present
    // and only the appID is passed: link will work, but deploy will need
    // an alias to know which app to publish. In this case, we set the alias
    // to the appID, and the alias argument is ignored if also specified.
    if (appID) {
      core.debug(`Linking ${appID}`)
      await exec(cleverCLI, ['link', appID, '--alias', appID])
      alias = appID
    }

    // If there are environment variables to pass to the application,
    // set them before deployment so the new instance can use them.
    for (const envName of Object.keys(extraEnv)) {
      const args = ['env', 'set']
      if (alias) {
        args.push('--alias', alias)
      }
      args.push(envName, extraEnv[envName])
      await exec(cleverCLI, args)
    }

    const args = ['deploy']
    if (appID) {
      args.push('--alias', appID)
    } else if (alias) {
      args.push('--alias', alias)
    }

    if (timeout) {
      let timeoutID: NodeJS.Timeout | undefined
      let timedOut = false
      const timeoutPromise = new Promise<void>(resolve => {
        timeoutID = setTimeout(() => {
          timedOut = true
          resolve()
        }, timeout)
      })
      const result = await Promise.race([exec(cleverCLI, args), timeoutPromise])
      if (timeoutID) {
        clearTimeout(timeoutID)
      }
      if (timedOut) {
        core.info('Deployment timed out, moving on with workflow run')
      }
      core.info(`result: ${result}`)
      if (typeof result === 'number' && result !== 0) {
        throw new Error(`Deployment failed with code ${result}`)
      }
    } else {
      const code = await exec(cleverCLI, args)
      core.info(`code: ${code}`)
      if (code !== 0) {
        throw new Error(`Deployment failed with code ${code}`)
      }
    }
  } catch (error) {
    if (error instanceof Error) {
      core.setFailed(error.message)
    } else {
      core.setFailed(String(error))
    }
  }
}