Redundant data computation

Hello,

I have to perform the same computation on each page, and a specific action shall be performed on each page according to the result.

Let’s say compare 2 boolean states of the page. The rule / the calculation is always the same, let’s say XOR. According to the result a specific redirection will be performed.

I have started like adding this XOR computation in workflows of each page, but now I want to define this rule only once.

Then my question is : how to define only once a calculation/actions used many times ? How to reuse this kind of stuff ?

I have created an API workflow fed with 2 boolean parameters and returning the XOR result. However, I can’t not find a way to retrieve the result in my front end. It seems like it is not possible…

Any suggestions ?