本文整理汇总了TypeScript中@aurelia/kernel.DI.createInterface方法的典型用法代码示例。如果您正苦于以下问题:TypeScript DI.createInterface方法的具体用法?TypeScript DI.createInterface怎么用?TypeScript DI.createInterface使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@aurelia/kernel.DI
的用法示例。
在下文中一共展示了DI.createInterface方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: dispatchSignal
import { DI, Immutable } from '@aurelia/kernel';
import { LifecycleFlags } from '../flags';
import { IPropertySubscriber } from '../observation';
type Signal = string;
export interface ISignaler {
signals: Immutable<Record<string, Set<IPropertySubscriber>>>;
dispatchSignal(name: Signal, flags?: LifecycleFlags): void;
addSignalListener(name: Signal, listener: IPropertySubscriber): void;
removeSignalListener(name: Signal, listener: IPropertySubscriber): void;
}
export const ISignaler = DI.createInterface<ISignaler>('ISignaler').withDefault(x => x.singleton(Signaler));
/** @internal */
export class Signaler implements ISignaler {
public signals: Record<string, Set<IPropertySubscriber>>;
constructor() {
this.signals = Object.create(null);
}
public dispatchSignal(name: Signal, flags?: LifecycleFlags): void {
const listeners = this.signals[name];
if (listeners === undefined) {
return;
}
for (const listener of listeners.keys()) {
listener.handleChange(undefined, undefined, flags | LifecycleFlags.updateTargetInstance);
}
示例2: start
return ProxyObserver.getProxyOrSelf(this._root);
}
public start(): this {
if (Profiler.enabled) { enterStart(); }
for (const runStartTask of this.startTasks) {
runStartTask();
}
this.isStarted = true;
if (Profiler.enabled) { leaveStart(); }
return this;
}
public stop(): this {
if (Profiler.enabled) { enterStop(); }
this.isStarted = false;
for (const runStopTask of this.stopTasks) {
runStopTask();
}
if (Profiler.enabled) { leaveStop(); }
return this;
}
}
(PLATFORM.global as typeof PLATFORM.global & {Aurelia: unknown}).Aurelia = Aurelia;
export const IDOMInitializer = DI.createInterface<IDOMInitializer>('IDOMInitializer').noDefault();
export interface IDOMInitializer {
initialize(config?: ISinglePageApp): IDOM;
}
示例3: provideEncapsulationSource
export type CustomElementHost<T extends INode = INode> = IRenderLocation<T> & T & {
$customElement?: ICustomElement<T>;
};
export interface IElementProjector<T extends INode = INode> {
readonly host: CustomElementHost<T>;
readonly children: ArrayLike<CustomElementHost<T>>;
provideEncapsulationSource(): T;
project(nodes: INodeSequence<T>): void;
take(nodes: INodeSequence<T>): void;
subscribeToChildrenChange(callback: () => void): void;
}
export const IProjectorLocator = DI.createInterface<IProjectorLocator>('IProjectorLocator').noDefault();
export interface IProjectorLocator<T extends INode = INode> {
getElementProjector(dom: IDOM<T>, $component: ICustomElement<T>, host: CustomElementHost<T>, def: TemplateDefinition): IElementProjector<T>;
}
export interface ICustomElementStaticProperties {
containerless?: TemplateDefinition['containerless'];
shadowOptions?: TemplateDefinition['shadowOptions'];
bindables?: TemplateDefinition['bindables'];
strategy?: TemplateDefinition['strategy'];
}
export interface ICustomElement<T extends INode = INode> extends
Partial<IChangeTracker>,
ILifecycleHooks,
示例4:
export type BindableDefinitions = Record<string, Immutable<IBindableDescription>>;
export interface IAttributeDefinition extends IResourceDefinition {
defaultBindingMode?: BindingMode;
aliases?: string[];
isTemplateController?: boolean;
hasDynamicOptions?: boolean;
bindables?: Record<string, IBindableDescription> | string[];
strategy?: BindingStrategy;
}
export type AttributeDefinition = Immutable<Required<IAttributeDefinition>> | null;
export type InstructionTypeName = string;
export const ITargetedInstruction = DI.createInterface<ITargetedInstruction>('createInterface').noDefault();
export interface ITargetedInstruction {
type: InstructionTypeName;
}
export type NodeInstruction =
IHydrateElementInstruction |
IHydrateTemplateController |
IHydrateLetElementInstruction;
export type AttributeInstruction =
IInterpolationInstruction |
IPropertyBindingInstruction |
IIteratorBindingInstruction |
ICallBindingInstruction |
IRefBindingInstruction |
示例5: createProperty
import { DI, PLATFORM, Reporter, Tracer } from '@aurelia/kernel';
import { LifecycleFlags } from '../flags';
import { IBindingTargetObserver, IObservable, IPropertySubscriber } from '../observation';
import { propertyObserver } from './property-observer';
export interface IDirtyChecker {
createProperty(obj: IObservable, propertyName: string): IBindingTargetObserver;
addProperty(property: DirtyCheckProperty): void;
removeProperty(property: DirtyCheckProperty): void;
}
export const IDirtyChecker = DI.createInterface<IDirtyChecker>('IDirtyChecker').withDefault(x => x.singleton(DirtyChecker));
export const DirtyCheckSettings = {
/**
* Default: `6`
*
* Adjust the global dirty check frequency.
* Measures in "frames per check", such that (given an FPS of 60):
* - A value of 1 will result in 60 dirty checks per second
* - A value of 6 will result in 10 dirty checks per second
*/
framesPerCheck: 6,
/**
* Default: `false`
*
* Disable dirty-checking entirely. Properties that cannot be observed without dirty checking
* or an adapter, will simply not be observed.
*/
disabled: false,
/**
示例6: isStandardSvgAttribute
import { DI } from '@aurelia/kernel';
import { INode } from '@aurelia/runtime';
export interface ISVGAnalyzer {
isStandardSvgAttribute(node: INode, attributeName: string): boolean;
}
export const ISVGAnalyzer = DI.createInterface<ISVGAnalyzer>('ISVGAnalyzer').withDefault(x => x.singleton(class {
public isStandardSvgAttribute(node: INode, attributeName: string): boolean {
return false;
}
})
);
示例7: constructor
constructor() {
this.statics = 0;
this.dynamics = 0;
this.symbols = 0;
}
}
export interface ISyntaxInterpreter {
add(def: AttributePatternDefinition): void;
add(defs: AttributePatternDefinition[]): void;
add(defOrDefs: AttributePatternDefinition | AttributePatternDefinition[]): void;
interpret(value: string): Interpretation;
}
export const ISyntaxInterpreter = DI.createInterface<ISyntaxInterpreter>('ISyntaxInterpreter').withDefault(x => x.singleton(SyntaxInterpreter));
/** @internal */
export class SyntaxInterpreter {
public rootState: State;
private readonly initialStates: State[];
constructor() {
this.rootState = new State(null);
this.initialStates = [this.rootState];
}
public add(def: AttributePatternDefinition): void;
public add(defs: AttributePatternDefinition[]): void;
public add(defOrDefs: AttributePatternDefinition | AttributePatternDefinition[]): void {
let i = 0;
示例8: findTargets
import { DI, IContainer, IResolver, PLATFORM, Reporter } from '@aurelia/kernel';
export interface INode extends Object { }
export const INode = DI.createInterface<INode>('INode').noDefault();
export const IRenderLocation = DI.createInterface<IRenderLocation>('IRenderLocation').noDefault();
export interface IRenderLocation<T extends INode = INode> extends INode {
$start?: IRenderLocation<T>;
$nodes?: INodeSequence<T> | Readonly<{}>;
}
/**
* Represents a DocumentFragment
*/
export interface INodeSequence<T extends INode = INode> extends INode {
/**
* The nodes of this sequence.
*/
readonly childNodes: ArrayLike<T>;
readonly firstChild: T;
readonly lastChild: T;
/**
* Find all instruction targets in this sequence.
*/
findTargets(): ArrayLike<T>;
/**