Skip to content

Commit

Permalink
feat: add ContributionOptionConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
sunshinesmilelk committed Apr 12, 2024
1 parent 2afd73f commit 76745bd
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
13 changes: 13 additions & 0 deletions .changeset/stupid-suns-occur.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
'@difizen/mana-syringe': patch
'@difizen/mana-docs': patch
'@difizen/mana-app': patch
'@difizen/mana-common': patch
'@difizen/mana-core': patch
'@difizen/mana-l10n': patch
'@difizen/mana-observable': patch
'@difizen/mana-react': patch
'@difizen/mana-ui': patch
---

feat: add ContributionOptionConfig
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,10 @@ export type Provider<T extends Record<string, any>> = {
export const Provider = Syringe.defineToken('SyringeContributionProvider', {
global: true,
});

export class ContributionOptionConfigImpl {
recursive: false;
cache: true;
}

export const ContributionOptionConfig = new ContributionOptionConfigImpl();
11 changes: 9 additions & 2 deletions packages/mana-syringe/src/contribution/contribution-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import { DisposableCollection } from '@difizen/mana-common';

import type { Syringe } from '../core';

import type { Option, Provider } from './contribution-protocol';
import {
ContributionOptionConfig,
type Option,
type Provider,
} from './contribution-protocol';

export class DefaultContributionProvider<T extends Record<string, any>>
implements Provider<T>, Disposable
Expand All @@ -13,7 +17,10 @@ export class DefaultContributionProvider<T extends Record<string, any>>
get onChanged() {
return this.onChangedEmitter.event;
}
protected option: Option = { recursive: false, cache: true };
protected option: Option = {
recursive: ContributionOptionConfig.recursive,
cache: ContributionOptionConfig.cache,
};
protected services: T[] | undefined;
protected readonly serviceIdentifier: Syringe.Token<T>;
protected readonly container: Syringe.Container;
Expand Down

0 comments on commit 76745bd

Please sign in to comment.