Lime Web Components API Documentation - v6.24.0
    Preparing search index...

    Type Alias Condition<T>Beta

    Represents a conditional evaluation rule that can be registered and used throughout the application.

    Conditions are predicate functions that determine whether certain UI elements should be visible, enabled, or available based on runtime state. For example, they can be used to:

    • Control action visibility (show/hide menu items based on object state)
    • Enable/disable features based on user permissions or context
    • Filter lists of items based on dynamic criteria
    • Implement business rules for conditional UI rendering

    Each condition has a unique ID and a type that indicates what kind of subject it evaluates. The most common types are 'limeobject' and 'action', but custom types can be defined.

    Registering a simple LimeObject condition

    const registry = platform.get(PlatformServiceName.ConditionRegistry);

    const isDealWon = {
    id: 'deal.is-won',
    type: 'limeobject',
    evaluate: (deal) => deal.dealstatus === 'won'
    };

    registry.addCondition(isDealWon);

    Condition with additional parameters

    const hasMinimumValue = {
    id: 'object.min-value',
    type: 'limeobject',
    evaluate: (object, params) => {
    const { field, minValue } = params;
    const value = object[field];
    return typeof value === 'number' && value >= minValue;
    }
    };

    const isHighValue = hasMinimumValue.evaluate(dealObject, {
    field: 'value',
    minValue: 100000
    });
    type Condition<T = unknown> = {
        id: string;
        type: ConditionType;
        evaluate(subject: T, params?: unknown): boolean;
    }

    Type Parameters

    • T = unknown
    Index

    Properties

    Methods

    Properties

    id: string

    Unique identifier for this condition.

    The ID is used to reference the condition when registering, removing, or looking it up from the ConditionRegistry. It must be unique across all registered conditions.

    The type of subject this condition evaluates.

    Common types include:

    • limeobject - Evaluates LimeObject instances
    • action - Evaluates Action instances

    Custom types can be defined for specialized evaluation contexts.

    Methods

    • The evaluation function that determines if the condition is met.

      This predicate function receives the subject to evaluate and optional parameters for configuration. It should return true if the condition is satisfied, false otherwise.

      The function should be pure and side-effect free when possible, as it may be called frequently during UI rendering and updates.

      Parameters

      • subject: T

        The value to evaluate. Type depends on the condition type. For 'limeobject' conditions, this is a LimeObject. For 'action' conditions, this is an Action.

      • Optionalparams: unknown

        Optional configuration data for the evaluation. Can be used to pass context-specific values like field names, thresholds, or other criteria. The evaluation function should validate params if used.

      Returns boolean

      true if the condition is met, false otherwise.

      May throw an error if params has an unexpected type or required data is missing.

      Simple boolean check

      const evaluate = (deal: LimeObject) => deal.dealstatus === 'won';
      

      Using params for configuration

      const evaluate = (obj: LimeObject, params?: { propertyName: string }) => {
      return obj.getValue(params.propertyName) !== null;
      };