Service container for the Lime CRM platform that provides access to all platform services.

The platform acts as a service locator for accessing repositories, the command bus, HTTP client, and other services throughout the application. It is used by web components (injected via Stencil's @Prop decorator), command handlers, and other parts of the system.

The platform type indicates which Lime CRM client is hosting the component:

  • LimeCRMWebClient: Standard web client
  • LimeCRMDesktopClient: Desktop application client
  • LimeCRMWebAdminClient: Administrative web interface

Example

// Get core services
const http = platform.get(PlatformServiceName.Http);
const commandBus = platform.get(PlatformServiceName.CommandBus);
const limetypes = platform.get(PlatformServiceName.LimeTypeRepository);

// Check platform type for conditional logic
if (platform.type === 'LimeCRMDesktopClient') {
// Desktop-specific functionality
}

// Check feature switches
if (platform.isFeatureEnabled('newFeature')) {
// Use new feature
}

Example

// Register a custom service (third-party plugins)
platform.register('myPlugin.analytics', new AnalyticsService());

// Later retrieve it
const analytics = platform.get('myPlugin.analytics');

Hierarchy

  • LimeWebComponentPlatform

Properties

Methods

Properties

type: "LimeCRMWebClient" | "LimeCRMDesktopClient" | "LimeCRMWebAdminClient"

The type of Lime CRM client currently running. Use this to conditionally enable features based on the client environment.

Methods

  • Check if a service is currently registered on the platform.

    Useful for optional dependencies or checking service availability.

    Returns

    true if the service is registered, false otherwise

    Example

    if (platform.has(PlatformServiceName.Analytics)) {
    const tracker = platform.get(PlatformServiceName.Analytics);
    tracker.track('event');
    }

    Parameters

    • name: string

      The name of the service to check

    Returns boolean

  • Check if a feature is enabled in the current environment.

    Feature switches allow gradual rollout of new functionality and environment-specific behavior. Features can be enabled/disabled at the application, user, or system level.

    Returns

    true if the feature is enabled, false otherwise

    Example

    // Use feature switches for gradual rollout
    if (platform.isFeatureEnabled('advancedSearch')) {
    return new AdvancedSearchComponent();
    } else {
    return new BasicSearchComponent();
    }

    Parameters

    • name: never

      Name of the feature switch to check

    Returns boolean

  • Register a service on the platform for use throughout the application.

    Service names are typically defined in the PlatformServiceName enum through module augmentation. This ensures type safety and prevents naming conflicts.

    Example

    const SERVICE_NAME = 'myPlugin.cache';
    PlatformServiceName.MyCache = SERVICE_NAME;

    declare module '@limetech/lime-web-components' {
    interface PlatformServiceNameType {
    MyCache: typeof SERVICE_NAME;
    }

    interface LimeWebComponentPlatform {
    get(name: PlatformServiceNameType['MyCache']): CacheService;
    }
    }

    // Register the service
    platform.register(PlatformServiceName.MyCache, new CacheService());

    Parameters

    • name: string

      The name to register the service under

    • service: any

      The service instance to register

    Returns void