зеркало из https://github.com/microsoft/jacdac-ts.git
fix: lazier about triggering change on spec updates
This commit is contained in:
Родитель
205ec69944
Коммит
459676250a
|
@ -1424,9 +1424,12 @@ ${dev
|
|||
* @param services
|
||||
*/
|
||||
setCustomServiceSpecifications(services: jdspec.ServiceSpec[]) {
|
||||
loadServiceSpecifications(services)
|
||||
this.clearDevices()
|
||||
this.emit(CHANGE)
|
||||
const res = loadServiceSpecifications(services)
|
||||
if (res.changed) {
|
||||
this.clearDevices()
|
||||
this.emit(CHANGE)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -38,7 +38,10 @@ export function loadServiceSpecifications(
|
|||
): {
|
||||
added: jdspec.ServiceSpec[]
|
||||
errors: { message: string; spec: jdspec.ServiceSpec }[]
|
||||
changed: boolean
|
||||
} {
|
||||
const previous = _serviceSpecifications
|
||||
|
||||
// combine builtin specs with new specs
|
||||
const builtins = (serviceSpecificationData ||
|
||||
[]) as any as jdspec.ServiceSpec[]
|
||||
|
@ -79,10 +82,12 @@ export function loadServiceSpecifications(
|
|||
}
|
||||
}
|
||||
|
||||
_serviceSpecifications = specs
|
||||
_serviceSpecificationMap = undefined
|
||||
|
||||
return { added, errors }
|
||||
const changed = JSON.stringify(previous) !== JSON.stringify(specs)
|
||||
if (changed) {
|
||||
_serviceSpecifications = specs
|
||||
_serviceSpecificationMap = undefined
|
||||
}
|
||||
return { added, errors, changed }
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Загрузка…
Ссылка в новой задаче