Lime Web Components API Documentation - v7.4.0
    Preparing search index...

    Interface LimeWebComponent

    Base interface that all Lime Web Components must implement.

    This interface ensures that every component has access to the LimeWebComponentPlatform service container and understands its LimeWebComponentContext within the application. In Stencil components, these are injected as properties using the @Prop decorator.

    import { PlatformServiceName } from '@limetech/lime-web-components';

    // Access services through the platform
    const repository = platform.get(PlatformServiceName.LimeObjectRepository);
    const translate = platform.get(PlatformServiceName.Translate);

    // Use the context to load the record the component is running for
    if (context.limetype && context.id) {
    const limeObject = await repository.loadObject(
    context.limetype,
    context.id
    );

    const heading = limeObject
    ? limeObject.getValue('name')
    : translate.get('missing_record');
    }
    import { PlatformServiceName } from '@limetech/lime-web-components';

    const loggerFactory = platform.get(PlatformServiceName.Logger);
    const logger = loggerFactory.createLogger('my-component');

    if (context.parent) {
    logger.debug('Running in a nested context', {
    current: context.limetype,
    parent: context.parent.limetype,
    });

    // Load the record the parent context points at
    if (context.parent.limetype && context.parent.id) {
    const repository = platform.get(
    PlatformServiceName.LimeObjectRepository
    );

    const parentObject = await repository.loadObject(
    context.parent.limetype,
    context.parent.id
    );
    }
    }

    The platform and context properties are fundamental to component operation:

    • platform provides access to all services (repositories, HTTP, command bus, etc.)
    • context describes where the component is running (which limetype, which record)
    interface LimeWebComponent {
        context: LimeWebComponentContext;
        platform: LimeWebComponentPlatform;
    }

    Hierarchy (View Summary)

    Index

    Properties

    Properties

    The context describing where this component is running.

    The context provides information about the current limetype and record ID (if viewing/editing a specific record). Components can use this to load relevant data and understand their operating environment.

    import { PlatformServiceName } from '@limetech/lime-web-components';

    const repository = platform.get(PlatformServiceName.LimeObjectRepository);

    if (context.limetype && context.id) {
    const limeObject = await repository.loadObject(
    context.limetype,
    context.id
    );
    }

    Reference to the platform service container.

    Use this to access all platform services like repositories, HTTP client, command bus, navigator, and more. The platform instance is shared across all components in the same application context.

    import { PlatformServiceName } from '@limetech/lime-web-components';

    const http = platform.get(PlatformServiceName.Http);
    const commandBus = platform.get(PlatformServiceName.CommandBus);
    const repository = platform.get(PlatformServiceName.LimeObjectRepository);