How to use the @aurelia/kernel.Registration.singleton function in @aurelia/kernel

To help you get started, we’ve selected a few @aurelia/kernel examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aurelia / aurelia / packages / testing / src / au-dom.ts View on Github external
register(container: IContainer): void {
    container.register(
      RuntimeConfiguration,
      AuTextRenderer as unknown as IRegistry,
      Registration.singleton(IDOM, AuDOM),
      Registration.singleton(IDOMInitializer, AuDOMInitializer),
      Registration.singleton(IProjectorLocator, AuProjectorLocator),
      Registration.singleton(ITargetAccessorLocator, AuObserverLocator),
      Registration.singleton(ITargetObserverLocator, AuObserverLocator),
      Registration.singleton(ITemplateFactory, AuTemplateFactory),
      Registration.instance(ITemplateCompiler, {}), // TODO: fix this dep tree
    );
  },
  createContainer(): IContainer {
github aurelia / aurelia / packages / validation / src / configuration.ts View on Github external
register(container: IContainer) {
      const options: ValidationCustomizationOpions = { validator: StandardValidator, customMessages: [], defaultTrigger: ValidationTrigger.blur };
      optionsProvider(options);

      return container.register(
        Registration.callback(ICustomMessages, () => options.customMessages),
        Registration.callback(IDefaultTrigger, () => options.defaultTrigger),
        Registration.singleton(IValidator, options.validator),
        Registration.singleton(IValidationMessageProvider, ValidationMessageProvider), // TODO enable customization of messages and i18n
        Registration.transient(IValidationRules, ValidationRules),
        ValidateBindingBehavior,
        ValidationErrorsCustomAttribute,
        ValidationRendererCustomAttribute,
        Registration.singleton(IValidationControllerFactory, ValidationControllerFactory)
      );
    },
    customize(cb?: ValidationConfigurationProvider) {
github aurelia / aurelia / packages / __tests__ / 1-kernel / di.spec.ts View on Github external
it(`stores resource resolvers in resourceResolvers in parent and inherits them from root but does not from parent`, function () {
        const type = class {};
        const keyFromRoot = 'foo:bar' as any;
        const keyFromParent = 'foo:baz' as any;

        const root = DI.createContainer();

        root.register(Registration.singleton(keyFromRoot, type));

        const parent = root.createChild();

        parent.register(Registration.singleton(keyFromParent, type));

        const parentHasKeyFromRoot = parent['resourceResolvers'][keyFromRoot] !== void 0;
        const parentHasKeyFromParent = parent['resourceResolvers'][keyFromParent] !== void 0;

        const child = parent.createChild();

        const childHasKeyFromRoot = child['resourceResolvers'][keyFromRoot] !== void 0;
        const childHasKeyFromParent = child['resourceResolvers'][keyFromParent] !== void 0;

        assert.strictEqual(parentHasKeyFromRoot, true, `parentHasKeyFromRoot`);
        assert.strictEqual(parentHasKeyFromParent, true, `parentHasKeyFromParent`);
github aurelia / aurelia / packages / testing / src / au-dom.ts View on Github external
register(container: IContainer): void {
    container.register(
      RuntimeBasicConfiguration,
      AuTextRenderer as unknown as IRegistry,
      Registration.singleton(IDOM, AuDOM),
      Registration.singleton(IDOMInitializer, AuDOMInitializer),
      Registration.singleton(IProjectorLocator, AuProjectorLocator),
      Registration.singleton(ITargetAccessorLocator, AuObserverLocator),
      Registration.singleton(ITargetObserverLocator, AuObserverLocator),
      Registration.singleton(ITemplateFactory, AuTemplateFactory)
    );
  },
  createContainer(): IContainer {
github aurelia / aurelia / packages / testing / dist / esnext / au-dom.js View on Github external
register(container) {
        container.register(RuntimeConfiguration, AuTextRenderer, Registration.singleton(IDOM, AuDOM), Registration.singleton(IDOMInitializer, AuDOMInitializer), Registration.singleton(IProjectorLocator, AuProjectorLocator), Registration.singleton(ITargetAccessorLocator, AuObserverLocator), Registration.singleton(ITargetObserverLocator, AuObserverLocator), Registration.instance(ITemplateCompiler, {}));
    },
    createContainer() {
github aurelia / aurelia / packages / __tests__ / setup-test262.ts View on Github external
public constructor() {
    const container = this.container = DI.createContainer();
    container.register(
      Registration.instance(ILogConfig, new LogConfig(ColorOptions.noColors, LogLevel.info)),
      Registration.instance(ISink, new BufferedFileSink()),
      Registration.instance(ISink, new ConsoleSink(console)),
      Registration.singleton(IFileSystem, NodeFileSystem),
    );
    this.fs = container.get(IFileSystem);
    this.logger = container.get(ILogger).scopeTo('TestRunner');
  }
github aurelia / aurelia / packages / i18n / dist / esnext / configuration.js View on Github external
register(container) {
            return container.register(Registration.callback(I18nInitOptions, () => options.initOptions), StartTask.with(I18N).beforeBind().call(i18n => i18n.task), Registration.singleton(I18nWrapper, I18nextWrapper), Registration.singleton(I18N, I18nService), ...renderers, ...translation);
        }
    };
github aurelia / aurelia / packages / runtime / dist / esnext / lifecycle.js View on Github external
static register(container) {
        return Registration.singleton(ILifecycle, this).register(container);
    }
}
github aurelia / aurelia / packages / jit-html / dist / index.es6.js View on Github external
static register(container) {
        return Registration.singleton(ITemplateCompiler, this).register(container);
    }
    compile(dom, definition, descriptions) {
github aurelia / aurelia / packages / runtime / src / observation / observer-locator.ts View on Github external
public static register(container: IContainer): IResolver {
    return Registration.singleton(IObserverLocator, this).register(container);
  }