Extend StackState with functions

Extending StackState's capabilities using functions.

StackState is built to deal with a wide variety of different situations. StackState comes with functions to stay flexible enough to account for different types of logic.

Functions are predefined scripts that transform input into an output. Functions are called by StackState on-demand. For example, when a component changed state, some new telemetry flowed in or when the user triggered an action.

Packaging functions

Functions give advanced users the ability to customize StackState fully. However, everyday users of StackState should not need to know that they exist.

StackPacks pre-package functions and automatically install functions on StackState whenever the StackPack gets installed. You can develop your function in StackState. When you are confident that it does what you want, you can export it and package it with a StackPack. Read more about it in how to create StackPacks.

Async vs synchronous functions

Functions in StackState can be either synchronous or asynchronous (async).

Function

Synchronous

Async

Event handler function

βœ…

βœ… (from v4.2)

Propagation functions

βœ…

βœ…

Baseline function

βœ…

-

Check function

βœ…

-

Component actions

-

βœ…

Component mapper function

βœ…

-

Id extractor function

βœ…

-

Relation mapper function

βœ…

-

Async functions

Propagation functions and event handler functions can be created as asynchronous (async) functions, while component action scripts always run as async. This gives them access to all StackState Script APIs and allows more functions to run in parallel.

Read more about:

Synchronous functions

In StackState, functions are generally written in a synchronous blocking manner.

Read more about: