Function Provider

  • Provider of base classes. Extending this mixin-style function while supplying the typeof a Provided constructor enforces type safety and hinting on the supplied magic string and the resulting class which extends this Provider mixin. The main purpose of this pattern is bridging module gaps by de-coupling bundle files while maintaining a well-defined prototype chain. This still requires the base class to be defined (and Provided) before extension but allows intellisense'd OOP patterns across multiple modules while maintaining runtime language specifications.

    Type Parameters

    Parameters

    • provider: K

      A magic string to retrieve the provider by.

    Returns V

    The constructor which Provides the Registration.

    Example

    Extend a provided class:

    import { Provider } from '@sgrud/core';
    import { type Base } from 'example-module';

    export class Class
    extends Provider<typeof Base>('sgrud.example.Base') {

    public constructor(...args: any[]) {
    super(...args);
    }

    }

    See

Generated using TypeDoc