Skip to main content
Version: 2.4

Logic - Functions vs Actions

Introduction

Even if Functions and Actions are very close, they have each some specificities:

FunctionsActions
iconUsage examplesCompute text of Button, Compute position of UI Component, Compute math operation, …Create object in database, send email, perform authentication, …
iconExecuted whenAll inputs are resolved (= have a value) or any input changesThe Control Flow input receives a new “pulse” (e.g. an interaction)
iconOrder of execution is guaranteedNoYes
iconCan call other functionsYesYes
iconCan call other actionsNoYes

Custom reusable functions & actions

Custom reusable Functions and Actions can be created in a project.

Inputs and Outputs can be added to the Function / Action:

function_new_input

Actions automatically come with Control Flow Inputs and Outputs:

action_control_flows

Function and Actions can be tested using play button:

test_function

Best practices

When a function or an action becomes complex, try to create smaller functions/actions and call them from a higher level function/action.

It is a good habit to create reusable functions/actions for any logic that is not directly related to User Interface.

Exercise 9 – Reusable function

The goal of this exercise is to create a reusable function which sums 3 numbers and return the result. This exercise is not linked to the Note app and is here for training purpose.

  1. Go to Project “Notes”.
  2. Open Folder “Logic”.
  3. Create a new Function named “Add 3”.
  4. Open the new Function and complete it as follow:

action_control_flows