Beta Registers a new condition in the registry.
The condition's ID must be unique across all registered conditions. If a condition with the same ID already exists, this method throws an error. It's recommended to register conditions during application startup.
Error if a condition with the same ID already exists in the registry.
const isActive: LimeObjectCondition = {
id: 'deal.is-active',
type: 'limeobject',
evaluate: (deal) => deal.dealstatus === 'active'
};
registry.addCondition(isActive);
The condition to register. Must have a unique ID.
Retrieves a specific condition by its unique identifier.
If no condition with the given ID exists, this method throws an error. Use hasCondition first if you need to check for existence.
The condition with the specified ID.
Error if no condition with the given ID exists in the registry.
const canWin = registry.getCondition('deal.can-win');
const isEligible = canWin.evaluate(dealObject);
Safe retrieval with type checking
const condition = registry.getCondition('deal.is-active');
if (isLimeObjectCondition(condition)) {
const result = condition.evaluate(myDeal);
}
The unique identifier of the condition to retrieve.
Retrieves all registered conditions.
This method returns a list of all conditions currently in the registry, regardless of their type. This can be useful for debugging, inspection, or building dynamic UIs that need to enumerate available conditions.
An array of all registered conditions.
const allConditions = registry.getConditions();
console.log(`Found ${allConditions.length} conditions`);
const limeObjectConditions = allConditions.filter(
c => c.type === 'limeobject'
);
Checks whether a condition with the given ID exists in the registry.
This method is useful for defensive programming, allowing you to verify that a condition exists before attempting to retrieve or remove it.
true if a condition with the ID exists, false otherwise.
if (registry.hasCondition('deal.can-win')) {
const condition = registry.getCondition('deal.can-win');
const canWin = condition.evaluate(deal);
}
The unique identifier of the condition to check.
Removes a condition from the registry.
The condition is identified by its ID. If no condition with the given ID exists in the registry, this method throws an error.
Error if the condition's ID does not exist in the registry.
const condition = registry.getCondition('deal.is-active');
registry.removeCondition(condition);
Safe removal with existence check
if (registry.hasCondition('deal.is-active')) {
registry.removeCondition(registry.getCondition('deal.is-active'));
}
The condition to remove. Must exist in the registry.
Central registry for managing conditional evaluation rules across the application.
The ConditionRegistry acts as a global repository for Condition instances, allowing different parts of the application to register, retrieve, and evaluate conditions. This is particularly useful for:
Components typically access the registry via the platform service and register their conditions when the application initializes. Conditions can be added and removed dynamically, allowing for flexible runtime configuration.
Example
Registering and using conditions in a component
See