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


TypeScript atom.Emitter類代碼示例

本文整理匯總了TypeScript中atom.Emitter的典型用法代碼示例。如果您正苦於以下問題:TypeScript Emitter類的具體用法?TypeScript Emitter怎麽用?TypeScript Emitter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: Error

 public addParamSpec<T>(
   pluginName: string,
   paramName: string,
   spec: UPI.IParamSpec<T>,
 ) {
   let pluginConfig = this.plugins.get(pluginName)
   if (!pluginConfig) {
     pluginConfig = new Map()
     this.plugins.set(pluginName, pluginConfig)
   }
   if (pluginConfig.has(paramName)) {
     throw new Error(`Parameter ${pluginName}.${paramName} already defined!`)
   }
   let value: T | undefined = this.saved[`${pluginName}.${paramName}`] as T
   if (value === undefined) {
     value = spec.default
   }
   pluginConfig.set(paramName, { spec, value })
   this.emitter.emit('did-update', { pluginName, paramName, value })
   return new Disposable(() => {
     if (pluginConfig) {
       pluginConfig.delete(paramName)
       if (pluginConfig.size === 0) {
         this.plugins.delete(pluginName)
       }
     }
   })
 }
開發者ID:atom-haskell,項目名稱:ide-haskell,代碼行數:28,代碼來源:param-store.ts

示例2: callback

 public onDidUpdate<T>(
   pluginName: string,
   paramName: string,
   callback: TUpdatedCallback<T>,
 ) {
   return this.emitter.on('did-update', (val) => {
     if (val.pluginName === pluginName && val.paramName === paramName) {
       callback(val)
     }
   })
 }
開發者ID:atom-haskell,項目名稱:ide-haskell,代碼行數:11,代碼來源:param-store.ts

示例3: didUpdate

 public didUpdate(providerId: number, msgs: ResultItem[]) {
   const uris: string[] = msgs.map((v) => v.uri).filter(notUndefined)
   for (const [k, v] of Array.from(this.messages)) {
     if (
       v.providerId === providerId ||
       (v.uri !== undefined && uris.includes(v.uri))
     ) {
       this.messages.delete(k)
     }
   }
   for (const msg of msgs) {
     this.messages.set(msg.hash(), msg)
   }
   const severities: Set<UPI.TSeverity> = new Set(msgs.map((v) => v.severity))
   this.emitter.emit('did-update', Array.from(severities))
 }
開發者ID:atom-haskell,項目名稱:ide-haskell,代碼行數:16,代碼來源:index.ts

示例4:

 public async setValue<T>(
   pluginName: string,
   paramName: string,
   value?: T,
 ): Promise<T | undefined> {
   const paramConfig = await this.getParamConfig<T>(
     pluginName,
     paramName,
     'set',
   )
   if (paramConfig === undefined) return undefined
   if (value === undefined) {
     value = await this.showSelect<T>(paramConfig)
   }
   if (value !== undefined) {
     paramConfig.value = value
     this.saved[`${pluginName}.${paramName}`] = value
     this.emitter.emit('did-update', { pluginName, paramName, value })
   }
   return value
 }
開發者ID:atom-haskell,項目名稱:ide-haskell,代碼行數:21,代碼來源:param-store.ts

示例5: onDidUpdate

 public onDidUpdate(callback: TUpdateCallback) {
   return this.emitter.on('did-update', callback)
 }
開發者ID:atom-haskell,項目名稱:ide-haskell,代碼行數:3,代碼來源:index.ts

示例6: onQueueIdle

 public onQueueIdle(callback: () => void) {
   return this.emitter.on('queue-idle', callback)
 }
開發者ID:mvoidex,項目名稱:atom-haskell-hsdev,代碼行數:3,代碼來源:index.ts

示例7: onBackendIdle

 public onBackendIdle(callback: () => void) {
   return this.emitter.on('backend-idle', callback)
 }
開發者ID:mvoidex,項目名稱:atom-haskell-hsdev,代碼行數:3,代碼來源:index.ts

示例8: onBackendActive

 public onBackendActive(callback: () => void) {
   return this.emitter.on('backend-active', callback)
 }
開發者ID:mvoidex,項目名稱:atom-haskell-hsdev,代碼行數:3,代碼來源:index.ts

示例9: onError

 public onError(callback: (error: IErrorCallbackArgs) => void) {
   return this.emitter.on('error', callback)
 }
開發者ID:mvoidex,項目名稱:atom-haskell-hsdev,代碼行數:3,代碼來源:index.ts

示例10: onWarning

 public onWarning(callback: (warning: string) => void) {
   return this.emitter.on('warning', callback)
 }
開發者ID:mvoidex,項目名稱:atom-haskell-hsdev,代碼行數:3,代碼來源:index.ts


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