Skip to content

Commit

Permalink
refactor(lifecycle): use default registration
Browse files Browse the repository at this point in the history
  • Loading branch information
fkleuver committed Oct 12, 2020
1 parent 71ed8e5 commit 77c88a2
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 24 deletions.
4 changes: 0 additions & 4 deletions packages/runtime/src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import {
IContainer,
IRegistry
} from '@aurelia/kernel';
import { Lifecycle } from './lifecycle';
import { ObserverLocator } from './observation/observer-locator';
import {
CallBindingRenderer,
CustomAttributeRenderer,
Expand Down Expand Up @@ -59,7 +57,6 @@ export const RefAttributePatternRegistration = RefAttributePattern as unknown as
export const DotSeparatedAttributePatternRegistration = DotSeparatedAttributePattern as unknown as IRegistry;

export const IExpressionParserRegistration = ExpressionParser as IRegistry;
export const ILifecycleRegistration = Lifecycle as IRegistry;
export const IRendererRegistration = Renderer as IRegistry;
export const IViewLocatorRegistration = ViewLocator as IRegistry;
export const IProjectionProviderRegistration = ProjectionProvider as IRegistry;
Expand Down Expand Up @@ -121,7 +118,6 @@ export const DefaultBindingLanguage = [
*/
export const DefaultComponents = [
IExpressionParserRegistration,
ILifecycleRegistration,
IRendererRegistration,
IViewLocatorRegistration,
Now,
Expand Down
1 change: 0 additions & 1 deletion packages/runtime/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,6 @@ export {

DefaultResources,
IExpressionParserRegistration,
ILifecycleRegistration,
IRendererRegistration,
IViewLocatorRegistration,
IProjectionProviderRegistration,
Expand Down
15 changes: 4 additions & 11 deletions packages/runtime/src/lifecycle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -586,12 +586,6 @@ export interface IHydratedCustomAttributeViewModel<T extends INode = INode> exte
readonly $controller: ICustomAttributeController<T, this>;
}

export interface ILifecycle {
readonly batch: IAutoProcessingQueue<IBatchable>;
}

export const ILifecycle = DI.createInterface<ILifecycle>('ILifecycle').withDefault(x => x.singleton(Lifecycle));

export interface IProcessingQueue<T> {
add(requestor: T): void;
process(flags: LifecycleFlags): void;
Expand Down Expand Up @@ -654,10 +648,9 @@ export class BatchQueue implements IAutoProcessingQueue<IBatchable> {
}
}

export class Lifecycle implements ILifecycle {
public readonly batch: IAutoProcessingQueue<IBatchable> = new BatchQueue(this);
export interface ILifecycle extends Lifecycle {}
export const ILifecycle = DI.createInterface<ILifecycle>('ILifecycle').withDefault(x => x.singleton(Lifecycle));

public static register(container: IContainer): IResolver<ILifecycle> {
return Registration.singleton(ILifecycle, this).register(container);
}
export class Lifecycle {
public readonly batch: IAutoProcessingQueue<IBatchable> = new BatchQueue(this);
}
2 changes: 0 additions & 2 deletions packages/testing/src/test-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
IDirtyChecker,

ILifecycle,
ILifecycleRegistration,
IObserverLocator,
Scope,
ITargetAccessorLocator,
Expand Down Expand Up @@ -458,7 +457,6 @@ export function createObserverLocator(containerOrLifecycle?: IContainer | ILifec
let container: IContainer;
if (containerOrLifecycle === undefined || !('get' in containerOrLifecycle)) {
container = DI.createContainer();
container.register(ILifecycleRegistration);
} else {
container = containerOrLifecycle;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {
IExpressionParserRegistration,
ILifecycleRegistration,
IRendererRegistration,
IProjectionProviderRegistration,

Expand Down Expand Up @@ -42,7 +41,6 @@ import { App } from './app';
global['Aurelia'] = new Aurelia()
.register(
IExpressionParserRegistration,
ILifecycleRegistration,
IRendererRegistration,
IProjectionProviderRegistration,

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {
IExpressionParserRegistration,
ILifecycleRegistration,
IRendererRegistration,
IStartTaskManagerRegistration,
IProjectionProviderRegistration,
Expand Down Expand Up @@ -43,7 +42,6 @@ import { App } from './app';
global['Aurelia'] = new Aurelia()
.register(
IExpressionParserRegistration,
ILifecycleRegistration,
IRendererRegistration,
IStartTaskManagerRegistration,
IProjectionProviderRegistration,
Expand Down
2 changes: 0 additions & 2 deletions test/kitchen-sink/src/startup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as faker from 'faker';
import { TraceConfiguration, DebugConfiguration } from '@aurelia/debug';
import {
Aurelia,
ILifecycleRegistration,
IRendererRegistration,
IfRegistration,
ElseRegistration,
Expand Down Expand Up @@ -67,7 +66,6 @@ Tracer.enableLiveLogging({
// to use (yet)
const container = DI.createContainer().register(
// runtime components
ILifecycleRegistration,
IRendererRegistration,

// runtime resources
Expand Down

0 comments on commit 77c88a2

Please sign in to comment.