Skip to content

Commit

Permalink
Updated form collection inheritance
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrei15193 committed Nov 17, 2024
1 parent d92c14d commit bf55844
Show file tree
Hide file tree
Showing 14 changed files with 139 additions and 132 deletions.
4 changes: 2 additions & 2 deletions src/dependencies/DependencyContainer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { IDependencyContainer, ConfigurableDependency, DependencyFactoryCallback } from "./IDependencyContainer";
import { type IDependencyResolver, type ResolvableSimpleDependency, type BasicDependency, type SimpleDependency, type ComplexDependency, DependencyToken } from "./IDependencyResolver";
import type { IDependencyContainer, ConfigurableDependency, DependencyFactoryCallback } from './IDependencyContainer';
import { type IDependencyResolver, type ResolvableSimpleDependency, type BasicDependency, type SimpleDependency, type ComplexDependency, DependencyToken } from './IDependencyResolver';

type DependencyFactoryKey<T> = DependencyToken<T> | BasicDependency<T> | SimpleDependency<T>;

Expand Down
8 changes: 4 additions & 4 deletions src/dependencies/DependencyResolverContext.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { IDependencyResolver, ResolvableSimpleDependency } from "./IDependencyResolver";
import type { IDependencyContainer, ConfigurableDependency } from "./IDependencyContainer";
import type { IDependencyResolver, ResolvableSimpleDependency } from './IDependencyResolver';
import type { IDependencyContainer, ConfigurableDependency } from './IDependencyContainer';
import type { useDependency } from './UseDependency';
import { DependencyContainer } from "./DependencyContainer";
import { type PropsWithChildren, createContext, createElement, useContext, useMemo, useRef } from "react";
import { DependencyContainer } from './DependencyContainer';
import { type PropsWithChildren, createContext, createElement, useContext, useMemo, useRef } from 'react';

const DependencyResolverContext = createContext<IDependencyResolver>(new DependencyContainer());

Expand Down
2 changes: 1 addition & 1 deletion src/dependencies/IDependencyContainer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { IDependencyResolver, BasicDependency, SimpleDependency, ComplexDependency, DependencyToken, ResolvableSimpleDependency } from "./IDependencyResolver";
import type { IDependencyResolver, BasicDependency, SimpleDependency, ComplexDependency, DependencyToken, ResolvableSimpleDependency } from './IDependencyResolver';
import type { useDependency } from './UseDependency';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/dependencies/IDependencyResolver.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { IDependencyContainer, ConfigurableDependency } from "./IDependencyContainer";
import type { IDependencyContainer, ConfigurableDependency } from './IDependencyContainer';
import type { useDependency } from './UseDependency';

/**
Expand Down
6 changes: 3 additions & 3 deletions src/dependencies/UseDependency.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { IDependencyResolver, ResolvableSimpleDependency, ComplexDependency } from "./IDependencyResolver";
import type { IDependencyResolver, ResolvableSimpleDependency, ComplexDependency } from './IDependencyResolver';
import type { IDependencyContainer } from './IDependencyContainer';
import type { useViewModelDependency } from './UseViewModelDependency';
import { useMemo, useRef } from "react";
import { useDependencyResolver, type DependencyResolverProvider, type DependencyResolverScope } from "./DependencyResolverContext";
import { useMemo, useRef } from 'react';
import { useDependencyResolver, type DependencyResolverProvider, type DependencyResolverScope } from './DependencyResolverContext';

const emptyAdditionalDependencies: readonly unknown[] = [];

Expand Down
8 changes: 4 additions & 4 deletions src/dependencies/UseViewModelDependency.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { INotifyPropertiesChanged } from "../viewModels";
import type { IDependencyResolver, ResolvableSimpleDependency, ComplexDependency } from "./IDependencyResolver";
import type { INotifyPropertiesChanged } from '../viewModels';
import type { IDependencyResolver, ResolvableSimpleDependency, ComplexDependency } from './IDependencyResolver';
import type { IDependencyContainer, ConfigurableDependency } from './IDependencyContainer'
import { useViewModel } from "../hooks";
import { useDependency } from "./UseDependency";
import { useViewModel } from '../hooks';
import { useDependency } from './UseDependency';

/**
* Resolves the requested view model dependency and subscribes to it for changes.
Expand Down
10 changes: 5 additions & 5 deletions src/dependencies/__tests__/DependencyContainer.circular.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { DependencyToken, type IDependencyResolver } from "../IDependencyResolver";
import { DependencyContainer } from "../DependencyContainer";
import { DependencyToken, type IDependencyResolver } from '../IDependencyResolver';
import { DependencyContainer } from '../DependencyContainer';

describe('DependencyContainer.circular', (): void => {
test("Attempting to resolve self referencing dependency throws exception", () => {
test('Attempting to resolve self referencing dependency throws exception', () => {
class A {
private static _resolveCount = 0;

Expand All @@ -21,7 +21,7 @@ describe('DependencyContainer.circular', (): void => {
expect(() => resolve(A)).toThrow(new Error('Circular dependency detected while trying to resolve \'A -> A\'.'));
});

test("Attempting to resolve circular dependency throws exception", () => {
test('Attempting to resolve circular dependency throws exception', () => {
class A {
private static _resolveCount = 0;

Expand Down Expand Up @@ -52,7 +52,7 @@ describe('DependencyContainer.circular', (): void => {
});


test("Attempting to resolve circular dependency with tokens throws exception", () => {
test('Attempting to resolve circular dependency with tokens throws exception', () => {
const dependencyTokenA = new DependencyToken('token A');
const dependencyTokenB = new DependencyToken('token B');

Expand Down
48 changes: 24 additions & 24 deletions src/dependencies/__tests__/DependencyContainer.config.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { DependencyToken } from "../IDependencyResolver";
import { DependencyContainer } from "../DependencyContainer";
import { DependencyToken } from '../IDependencyResolver';
import { DependencyContainer } from '../DependencyContainer';

describe('DependencyContainer.config', (): void => {
test("Configuring a type as singleton then as scoped updates the configuration", () => {
test('Configuring a type as singleton then as scoped updates the configuration', () => {
class MyClass {
}

Expand All @@ -20,7 +20,7 @@ describe('DependencyContainer.config', (): void => {
expect(secondInstance).not.toBe(thirdInstance);
});

test("Configuring a type as scoped then as singleton updates the configuration", () => {
test('Configuring a type as scoped then as singleton updates the configuration', () => {
class MyClass {
}

Expand All @@ -38,7 +38,7 @@ describe('DependencyContainer.config', (): void => {
expect(secondInstance).toBe(thirdInstance);
});

test("Configuring a type as singleton then as transient updates the configuration", () => {
test('Configuring a type as singleton then as transient updates the configuration', () => {
class MyClass {
}

Expand All @@ -56,7 +56,7 @@ describe('DependencyContainer.config', (): void => {
expect(secondInstance).not.toBe(thirdInstance);
});

test("Configuring a type as transient then as singleton updates the configuration", () => {
test('Configuring a type as transient then as singleton updates the configuration', () => {
class MyClass {
}

Expand All @@ -74,7 +74,7 @@ describe('DependencyContainer.config', (): void => {
expect(secondInstance).toBe(thirdInstance);
});

test("Configuring a type as scoped then as transient updates the configuration", () => {
test('Configuring a type as scoped then as transient updates the configuration', () => {
class MyClass {
}

Expand All @@ -92,7 +92,7 @@ describe('DependencyContainer.config', (): void => {
expect(secondInstance).not.toBe(thirdInstance);
});

test("Configuring a type as transient then as scoped updates the configuration", () => {
test('Configuring a type as transient then as scoped updates the configuration', () => {
class MyClass {
}

Expand All @@ -110,8 +110,8 @@ describe('DependencyContainer.config', (): void => {
expect(secondInstance).not.toBe(thirdInstance);
});

test("Configuring a token as singleton then as scoped updates the configuration", () => {
const token = new DependencyToken<MyClass>("test-dependency-token");
test('Configuring a token as singleton then as scoped updates the configuration', () => {
const token = new DependencyToken<MyClass>('test-dependency-token');
class MyClass {
}

Expand All @@ -129,8 +129,8 @@ describe('DependencyContainer.config', (): void => {
expect(secondInstance).not.toBe(thirdInstance);
});

test("Configuring a token as scoped then as singleton updates the configuration", () => {
const token = new DependencyToken<MyClass>("test-dependency-token");
test('Configuring a token as scoped then as singleton updates the configuration', () => {
const token = new DependencyToken<MyClass>('test-dependency-token');
class MyClass {
}

Expand All @@ -148,8 +148,8 @@ describe('DependencyContainer.config', (): void => {
expect(secondInstance).toBe(thirdInstance);
});

test("Configuring a token as singleton then as transient updates the configuration", () => {
const token = new DependencyToken<MyClass>("test-dependency-token");
test('Configuring a token as singleton then as transient updates the configuration', () => {
const token = new DependencyToken<MyClass>('test-dependency-token');
class MyClass {
}

Expand All @@ -167,8 +167,8 @@ describe('DependencyContainer.config', (): void => {
expect(secondInstance).not.toBe(thirdInstance);
});

test("Configuring a token as transient then as singleton updates the configuration", () => {
const token = new DependencyToken<MyClass>("test-dependency-token");
test('Configuring a token as transient then as singleton updates the configuration', () => {
const token = new DependencyToken<MyClass>('test-dependency-token');
class MyClass {
}

Expand All @@ -186,8 +186,8 @@ describe('DependencyContainer.config', (): void => {
expect(secondInstance).toBe(thirdInstance);
});

test("Configuring a token as scoped then as transient updates the configuration", () => {
const token = new DependencyToken<MyClass>("test-dependency-token");
test('Configuring a token as scoped then as transient updates the configuration', () => {
const token = new DependencyToken<MyClass>('test-dependency-token');
class MyClass {
}

Expand All @@ -205,8 +205,8 @@ describe('DependencyContainer.config', (): void => {
expect(secondInstance).not.toBe(thirdInstance);
});

test("Configuring a token as transient then as scoped updates the configuration", () => {
const token = new DependencyToken<MyClass>("test-dependency-token");
test('Configuring a token as transient then as scoped updates the configuration', () => {
const token = new DependencyToken<MyClass>('test-dependency-token');
class MyClass {
}

Expand All @@ -224,7 +224,7 @@ describe('DependencyContainer.config', (): void => {
expect(secondInstance).not.toBe(thirdInstance);
});

test("Child dependency container overrides parent singleton configuraiton without affecting it", () => {
test('Child dependency container overrides parent singleton configuraiton without affecting it', () => {
class MyClass {
}

Expand All @@ -249,7 +249,7 @@ describe('DependencyContainer.config', (): void => {
expect(firstInstanceFromChild).not.toBe(secondInstanceFromChild);
});

test("Child dependency container overrides parent transient configuraiton without affecting it", () => {
test('Child dependency container overrides parent transient configuraiton without affecting it', () => {
class MyClass {
}

Expand All @@ -274,7 +274,7 @@ describe('DependencyContainer.config', (): void => {
expect(firstInstanceFromChild).toBe(secondInstanceFromChild);
});

test("Child dependency container uses parent configuraiton as fallback", () => {
test('Child dependency container uses parent configuraiton as fallback', () => {
class MyFirstClass {
}
class MySecondClass {
Expand All @@ -295,7 +295,7 @@ describe('DependencyContainer.config', (): void => {
expect(secondChildInstance.instance).toBe(parentInstance);
});

test("Child dependency container uses own configuraiton when overridden", () => {
test('Child dependency container uses own configuraiton when overridden', () => {
class MyFirstClass {
}
class MySecondClass {
Expand Down
Loading

0 comments on commit bf55844

Please sign in to comment.