Skip to content

Commit

Permalink
feat(di): replace inverted by overridable
Browse files Browse the repository at this point in the history
BREAKING CHANGE:
Set inverted flag by default and rename it to "overridable".
  • Loading branch information
Vittly authored and yarastqt committed May 24, 2019
1 parent 470f39b commit 957a0fe
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/di/di.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function withRegistry(...registries: Registry[]) {
registries.forEach(registry => {
const overrides = contextRegistries[registry.id];

providedRegistries[registry.id] = registry.inverted
providedRegistries[registry.id] = registry.overridable
? overrides ? registry.merge(overrides) : registry
: (registry && overrides) ? overrides.merge(registry) : registry;
});
Expand Down Expand Up @@ -78,7 +78,7 @@ export const useComponentRegistry = <T extends {}>(id: string) => {

export interface IRegistryOptions {
id: string;
inverted?: boolean;
overridable?: boolean;
}

interface IRegistryComponents {
Expand All @@ -87,12 +87,12 @@ interface IRegistryComponents {

export class Registry {
id: string;
inverted: boolean;
overridable: boolean;
private components: IRegistryComponents = {};

constructor({ id, inverted = false }: IRegistryOptions) {
constructor({ id, overridable = true }: IRegistryOptions) {
this.id = id;
this.inverted = inverted;
this.overridable = overridable;
}

/**
Expand Down Expand Up @@ -135,7 +135,7 @@ export class Registry {
* @param registry external registry
*/
merge(registry: Registry) {
const clone = new Registry({ id: this.id, inverted: this.inverted });
const clone = new Registry({ id: this.id, overridable: this.overridable });

clone.components = {
...this.components,
Expand Down

0 comments on commit 957a0fe

Please sign in to comment.