Enums
An enum is an ordered list of entries, with a Value
and a Display Name
. The Value
is the actual value being used within dataflows, while the Display Name
is the text displayed in DRAW. Enums are treated as types within Olympe.
Let's have an example of an enum called "Currencies":
enum Currencies
{
EUR,
USD,
CHF
}
Create an Enum Folder
Create one by drag-and-dropping the Enum component from the Marketplace on the right side of the screen into the main editor.
Define the enums
After creating the enum, you can populate its values.
Each entry in an enum has a value
, which is an internal value used by the enum and a display name
, which can be a different text to be displayed to users. Reusing our list of currencies above, the value USD
could have US Dollar
as display name, and CHF
have Swiss Franc
.
The ordering of the values can also be changed using the up/down arrows.
Using an enum
Enums are seen as new types within DRAW. They can therefore be used wherever types are used:
- As types of properties within Data Types and Config Data Types
- As types of inputs and outputs in actions and functions.
- Ex: Core uses an enum to define the possible log levels for the
Debug Log
andLog
bricks. See their definition here: https://community.olympe.io/#editedItem=0179b269b5c75228d70f
- Ex: Core uses an enum to define the possible log levels for the
- As types of properties in visual components.
- Ex: Core uses enums to simplify the use of UI elements such as the
Button
, which can take several predefined variants. See their definitions here: https://community.olympe.io/#editedItem=017c78c7a7b6795d5151
- Ex: Core uses enums to simplify the use of UI elements such as the
Reusing an enum in another project
In case the current project is imported by other projects, you may want to set the visibility of the enum to public
. By doing so, the enum will be visible within the importing projects.