File size: 674 Bytes
f0634fb | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | import { collection } from '#/_base/di/collection';
import type { ServiceIdentifier } from '#/_base/di/instantiation';
import type { LifecycleScope } from '#/app/scopes';
export interface ContributedFeatureService {
readonly scope: LifecycleScope;
readonly id: ServiceIdentifier<unknown>;
}
export const FeatureServiceContribution = collection<ContributedFeatureService>(
'feature-service',
{
validate(value, existing) {
if (existing.some((entry) => entry.scope === value.scope && entry.id === value.id)) {
throw new Error(
`Service ${String(value.id)} is already contributed at scope ${value.scope}`,
);
}
},
},
);
|