當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript StateSwitch.off方法代碼示例

本文整理匯總了TypeScript中state-switch.StateSwitch.off方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript StateSwitch.off方法的具體用法?TypeScript StateSwitch.off怎麽用?TypeScript StateSwitch.off使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在state-switch.StateSwitch的用法示例。


在下文中一共展示了StateSwitch.off方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: quit

  public async quit (): Promise<void> {
    log.verbose('IoClient', 'quit()')

    if (this.state.off() === 'pending') {
      log.warn('IoClient', 'quit() with state.off() = `pending`, skipped')
      throw new Error('quit() with state.off() = `pending`')
    }

    this.state.off('pending')

    try {
      if (this.options.wechaty) {
        await this.options.wechaty.stop()
        // this.wechaty = null
      } else { log.warn('IoClient', 'quit() no this.wechaty') }

      if (this.io) {
        await this.io.stop()
        // this.io = null
      } else { log.warn('IoClient', 'quit() no this.io') }

    } catch (e) {
      log.error('IoClient', 'exception: %s', e.message)
      throw e
    } finally {
      this.state.off(true)
    }

    return

  }
開發者ID:zixia,項目名稱:wechaty,代碼行數:31,代碼來源:io-client.ts

示例2: start

  public async start (): Promise<void> {
    log.verbose('IoClient', 'init()')

    if (this.state.pending()) {
      log.warn('IoClient', 'start() with a pending state, not the time')
      const e = new Error('state.pending() when start()')
      throw e
    }

    this.state.on('pending')

    try {

      await this.startIo()
      await this.hookWechaty(this.options.wechaty)

      this.state.on(true)

    } catch (e) {
      log.error('IoClient', 'init() exception: %s', e.message)
      this.state.off(true)
      throw e
    }
    return
  }
開發者ID:zixia,項目名稱:wechaty,代碼行數:25,代碼來源:io-client.ts

示例3: stop

  public async stop (): Promise<void> {
    log.verbose('IoClient', 'stop()')

    this.state.off('pending')

    // XXX
    if (!this.io) {
      log.warn('IoClient', 'stop() without this.io')
      this.state.off(true)
      return
    }

    await this.io.stop()
    this.state.off(true)

    // XXX 20161026
    // this.io = null
    return
  }
開發者ID:zixia,項目名稱:wechaty,代碼行數:19,代碼來源:io-client.ts

示例4: stop

  public async stop(): Promise<void> {
    log.verbose('PuppetPadchatManager', `stop()`)

    this.state.off('pending')

    if (this.delayQueueExecutorSubscription) {
      this.delayQueueExecutorSubscription.unsubscribe()
      this.delayQueueExecutorSubscription = undefined
    } else {
      log.warn('PuppetPadchatManager', 'stop() subscript not exist')
    }

    await this.stopCheckScan()
    await super.stop()
    await this.releaseCache()

    this.userId          = undefined
    this.loginScanQrcode = undefined
    this.loginScanStatus = undefined

    this.state.off(true)
  }
開發者ID:miggame,項目名稱:wechaty,代碼行數:22,代碼來源:padchat-manager.ts

示例5: hookWechaty

  private async hookWechaty (wechaty: Wechaty): Promise<void> {
    log.verbose('IoClient', 'initWechaty()')

    if (this.state.off()) {
      const e = new Error('state.off() is true, skipped')
      log.warn('IoClient', 'initWechaty() %s', e.message)
      throw e
    }

    wechaty
    .on('login'	     , user => log.info('IoClient', `${user.name()} logined`))
    .on('logout'	   , user => log.info('IoClient', `${user.name()} logouted`))
    .on('scan', (url, code) => log.info('IoClient', `[${code}] ${url}`))
    .on('message'     , msg => this.onMessage(msg))

    return
  }
開發者ID:zixia,項目名稱:wechaty,代碼行數:17,代碼來源:io-client.ts

示例6: startIo

  private async startIo (): Promise<void> {
    log.verbose('IoClient', 'startIo() with token %s', this.options.token)

    if (this.state.off()) {
      const e = new Error('startIo() state.off() is true, skipped')
      log.warn('IoClient', e.message)
      throw e
    }

    try {
      await this.io.start()
    } catch (e) {
      log.verbose('IoClient', 'startIo() init fail: %s', e.message)
      throw e
    }

    return
  }
開發者ID:zixia,項目名稱:wechaty,代碼行數:18,代碼來源:io-client.ts


注:本文中的state-switch.StateSwitch.off方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。