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


TypeScript Observable.never方法代碼示例

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


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

示例1: makeTelegramDriver

export function makeTelegramDriver (
  token: Token,
  options: DriverOptions = {}
) {
  let state: TcombUpdatesState = {
    startDate: options.startDate || Date.now(),
    offset: 0,
    updates: []
  }

  let proxyUpdates = options.skipUpdates ? $.never<TcombUpdatesState>() : makeUpdates(state, token)
  let proxyWebHook = new Subject<any>()

  if (options.webhook) {
    proxyUpdates = makeWebHook(state, proxyWebHook)
  }

  let updates = proxyUpdates
    .doOnError((err: any) => {
      console.error('updates error: ', err)
      console.warn('Waiting 30 seconds before retry...')
    })
    .catch(proxyUpdates.delay(30000))
    .replay(null, 1)

  let sources = makeSources(updates)
  let disposable = updates.connect()

  function telegramDriver (sourceRequest: Observable<Observable<DriverSink>>, runSA: StreamAdapter): DriverExecution {
    let adapt = adapter(runSA)
    let request = sourceRequest.map(x => convertStream(x, runSA, RxAdapter))

    if (isWebhookResponse(request, options)) {
      handleWebhook(token, request, proxyWebHook)
    }

    let responses = handleRequest(token, request as Observable<Observable<TcombRequest>>).share()
    responses.subscribeOnError((err: any) => console.error('request error: ', err))

    return Object.assign(
      {
        token,
        dispose: () => disposable.dispose()
      },
      mapObjIndexed(adapt, {
        events: makeEventsSelector(sources),
        updates,
        responses
      })) as DriverExecution
  }

  (telegramDriver as any).streamAdapter = RxAdapter

  return telegramDriver
}
開發者ID:goodmind,項目名稱:cycle-telegram,代碼行數:55,代碼來源:telegram-driver.ts


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