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


TypeScript CompositeDisposable.add方法代碼示例

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


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

示例1:

            .then(() => {
                subscriptions.add(atom.commands.add('atom-workspace', {
                    'api-workbench:popular-apis': apiList.showPopularApis,
                    'api-workbench:editor-tools':editorTools.initEditorTools,
                    'api-workbench:console': Console.toggle,
                    'api-workbench:go-to-definition':decl.gotoDeclaration,
                    'api-workbench:find-usages':decl.findUsages,
                    'api-workbench:quick-outline':quickOutline.show,
                    'api-workbench:quick-commands': quickCommands.showCommands,
                    'api-workbench:rename':decl.renameRAMLElement,
                    'api-workbench:new-project':decl.newProject,
                    'api-workbench:select-node':decl.select
                }))

                subscriptions.add(atom.workspace.addOpener(Console.opener))
                //subscriptions.add(atom.workspace.addOpener(RamlScriptReport.opener))

                commandManager.initialize()
                contextMenu.initialize()
                commonContextActions.initialize()

                quickCommands.registerCommands()
                quickFixActions.initialize()

                editorTools.initEditorTools()
            })
開發者ID:andjarnic,項目名稱:api-workbench,代碼行數:26,代碼來源:main.ts

示例2: registerCommands

export function registerCommands(deps: Dependencies): DisposableLike {
  const disp = new CompositeDisposable()
  for (const cmd of getCommands()) {
    if (cmd.selector === "atom-text-editor") {
      const d = cmd.desc(deps)
      disp.add(
        atom.commands.add(cmd.selector, cmd.command, {
          ...d,
          async didDispatch(e) {
            try {
              const editor = e.currentTarget.getModel()
              if (isTypescriptEditorWithPath(editor)) {
                await d.didDispatch(editor, () => e.abortKeyBinding())
              } else {
                e.abortKeyBinding()
                if (isTypescriptGrammar(editor)) {
                  atom.notifications.addWarning(
                    "Atom-TypeScript cancelled last command: Current editor has no file path",
                    {
                      description:
                        "Atom-TypeScript needs to determine the file path of the " +
                        `current editor to execute \`${cmd.command}\`, which it failed to do. ` +
                        "You probably just need to save the current file somewhere.",
                      dismissable: true,
                    },
                  )
                }
              }
            } catch (error) {
              handle(error as Error)
            }
          },
        }),
      )
    } else {
      const d = cmd.desc(deps)
      disp.add(
        atom.commands.add(cmd.selector, cmd.command, {
          ...d,
          async didDispatch() {
            try {
              await d.didDispatch()
            } catch (error) {
              handle(error as Error)
            }
          },
        }),
      )
    }
  }
  return disp
}
開發者ID:TypeStrong,項目名稱:atom-typescript,代碼行數:52,代碼來源:index.ts

示例3: constructor

 constructor(state: IState = {}) {
   this.disposables = new CompositeDisposable()
   this.emitter = new Emitter()
   this.disposables.add(this.emitter)
   this.saved = state
   this.plugins = new Map()
 }
開發者ID:atom-haskell,項目名稱:ide-haskell,代碼行數:7,代碼來源:param-store.ts

示例4: constructor

 constructor() {
   this.currentId = 0
   this.disposables = new CompositeDisposable()
   this.emitter = new Emitter()
   this.disposables.add(this.emitter)
   this.messages = new Map()
 }
開發者ID:atom-haskell,項目名稱:ide-haskell,代碼行數:7,代碼來源:index.ts

示例5: registerEvent

function registerEvent(
  name: string,
  manager: PluginManager,
  provider: Provider | undefined,
  cb: UPI.TSingleOrArray<UPI.TTextBufferCallback>,
  reg: (cb: UPI.TTextBufferCallback) => Disposable,
) {
  function wrapStatus(cb: UPI.TTextBufferCallback) {
    return async function(buffer: TextBuffer) {
      try {
        manager.backendStatus(name, { status: 'progress', detail: '' })
        const res = await cb(buffer)
        if (provider && Array.isArray(res)) provider.setMessages(res)
        manager.backendStatus(name, { status: 'ready', detail: '' })
      } catch (e) {
        manager.backendStatus(name, { status: 'warning', detail: `${e}` })
        console.warn(e)
      }
    }
  }
  if (Array.isArray(cb)) {
    const disp = new CompositeDisposable()
    for (const i of cb) {
      disp.add(reg(wrapStatus(i)))
    }
    return disp
  } else {
    return reg(wrapStatus(cb))
  }
}
開發者ID:atom-haskell,項目名稱:ide-haskell,代碼行數:30,代碼來源:index.ts

示例6: constructor

 constructor(private upiPromise: Promise<UPI.IUPIInstance>) {
   this.disposables = new CompositeDisposable()
   this.emitter = new Emitter()
   this.disposables.add(this.emitter)
   this.bufferDirMap = new WeakMap()
   this.backend = this.startBackend()
 }
開發者ID:mvoidex,項目名稱:atom-haskell-hsdev,代碼行數:7,代碼來源:index.ts

示例7: registerCommands

export function registerCommands(deps: Dependencies) {
  const disp = new CompositeDisposable()
  for (const {selector, command, desc} of getCommands()) {
    disp.add(atom.commands.add(selector, command, desc(deps)))
  }
  return disp
}
開發者ID:patrickemuller,項目名稱:atom-settings,代碼行數:7,代碼來源:index.ts

示例8: createBackend

 private async createBackend(): Promise<HsDevProcessReal> {
   const backend = await createHsDevProcessReal()
   this.disposables.add(
     backend.onError((arg) => this.emitter.emit('error', arg)),
     backend.onWarning((arg) => this.emitter.emit('warning', arg)),
   )
   return backend
 }
開發者ID:mvoidex,項目名稱:atom-haskell-hsdev,代碼行數:8,代碼來源:index.ts

示例9: onActivate

export function onActivate() {
    // Add subscriptions here
  subscriptions.add(
    atom.commands.add('atom-workspace', {
      'plugin-name:toggle': togglePanel
    }));
  return subscriptions;
}
開發者ID:ShMcK,項目名稱:atom-plugin-react-boilerplate,代碼行數:8,代碼來源:subscriptions.ts

示例10: consumeUPI

export function consumeUPI(service: UPI.IUPIRegistration) {
  if (!process || !disposables) { return undefined }
  tempDisposables && tempDisposables.dispose()
  tempDisposables = undefined
  const upiConsumer = new UPIConsumer(service, process)
  resolveUpiPromise(upiConsumer.upi)
  disposables.add(upiConsumer)
  return upiConsumer
}
開發者ID:mvoidex,項目名稱:atom-haskell-hsdev,代碼行數:9,代碼來源:atom-haskell-hsdev.ts


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