本文整理汇总了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()
})
示例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
}
示例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()
}
示例4: constructor
constructor() {
this.currentId = 0
this.disposables = new CompositeDisposable()
this.emitter = new Emitter()
this.disposables.add(this.emitter)
this.messages = new Map()
}
示例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))
}
}
示例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()
}
示例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
}
示例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
}
示例9: onActivate
export function onActivate() {
// Add subscriptions here
subscriptions.add(
atom.commands.add('atom-workspace', {
'plugin-name:toggle': togglePanel
}));
return subscriptions;
}
示例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
}