本文整理匯總了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)
}
}
})
}
示例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)
}
})
}
示例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))
}
示例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
}
示例5: onDidUpdate
public onDidUpdate(callback: TUpdateCallback) {
return this.emitter.on('did-update', callback)
}
示例6: onQueueIdle
public onQueueIdle(callback: () => void) {
return this.emitter.on('queue-idle', callback)
}
示例7: onBackendIdle
public onBackendIdle(callback: () => void) {
return this.emitter.on('backend-idle', callback)
}
示例8: onBackendActive
public onBackendActive(callback: () => void) {
return this.emitter.on('backend-active', callback)
}
示例9: onError
public onError(callback: (error: IErrorCallbackArgs) => void) {
return this.emitter.on('error', callback)
}
示例10: onWarning
public onWarning(callback: (warning: string) => void) {
return this.emitter.on('warning', callback)
}