Skip to main content

Composition Action

Composition action is a chunk of code which is executed as soon as the template is loaded. Composition action is the best place to make any changes that need to effect the template globally, such as creating a new variable or adding a new middleware. If you add middleware in the Composition action, you can rest assure that the middleware will get executed every time the data with the specific key is received. And if you define a variable in the Composition action, it will be accessible from any other action within the same Composition.

Composition action example
const MY_GLOBAL_VAR = 500;

loopic.useOnUpdate("_key", (key, value, next) => {
// Some logic
});

Code written inside Composition action will be executed inside the Composition object - if you call this, you will get a reference to the composition object that is holding frame action. That way you can easily reach some Composition properties and methods.