Otter rules-engine

Super cute Otter!

This package is an Otter Framework Module.

Description

Stable Version Bundle Size

This module provides a rules engine that can run on your user's browser to customize the (translations, [//]: # (Should we target placeholder or the component npmjs, and we add a section on the placeholder there?) placeholders and configurations) of your application at runtime.

The rules engine interprets a list of actions to execute based on the evaluation of Rulesets and their conditions. Conditions are logical expressions relying on operators and variables we call facts.

You can store your list of Rulesets on a static JSON file.

This mechanism allows you to bring UI personalization based on runtime events without the need of a backend service. This can be useful if you want to drive dynamic behavior.

For example, you could consider leveraging this feature to display assets based on the current season or for some special events, or to drive A/B testing on your components.

You will find more information on the concepts behind the rules engine in its dedicated documentation. For a demonstration of the rules engine capabilities, you can refer to the live example in the Otter showcase.

How to install

Example :
ng add @o3r/rules-engine

[!WARNING] This module requires @o3r/core to be installed.

How to use

The package exposes the RulesEngineRunnerService that can drive all the Otter customization-based services in order to personalize the user experience. On its own, the service will do nothing and will need action handlers to register with the list of supported actions and their implementation.

Not only this allows for a better extensibility of the service, but it also keeps the number of imported module to the bare minimum for a lighter application.

Find more information on the Otter rules engine documentation.

Examples

Several examples of the rules engine usage are available on the following links:

Generators

Otter framework provides a set of code generators based on Angular schematics.

Schematics Description How to use
add Include Otter rules-engine module in a library / application. ng add @o3r/rules-engine
rules-engine-to-component Add rules-engine to an Otter component ng g rules-engine-to-component
facts-service Generate a facts service ng g facts-service
operators Generate an operator ng g operator

Debug

A whole section of the Otter Chrome Devtool extension is dedicated to the debug of the rules engine with a visual representation of your Rulesets and a history of the run, conditions met and actions applied.

Find more information on the tool in the Otter Chrome Devtool extension documentation and its dedicated section in the rules engine documentation.

External links

More details regarding the way the rules engine is working can be found in the documentation.
A live example is available in the Otter Showcase Application with reference to its code source.

results matching ""

    No results matching ""