本文整理匯總了TypeScript中atom.Emitter.emit方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Emitter.emit方法的具體用法?TypeScript Emitter.emit怎麽用?TypeScript Emitter.emit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類atom.Emitter
的用法示例。
在下文中一共展示了Emitter.emit方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: Map
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)
}
}
})
}
示例2: 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))
}
示例3:
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
}
示例4: destroy
public destroy() {
this.backend.destroy()
this.emitter.emit('did-destroy')
this.disposables.dispose()
}
示例5:
backend.onWarning((arg) => this.emitter.emit('warning', arg)),
示例6: debug
this.proc.once('exit', (code) => {
this.timer && window.clearTimeout(this.timer)
debug(`hsdev ended with ${code}`)
this.emitter.emit('did-exit', code)
this.disposables.dispose()
})