Codelessly Documentation
  • 👋Getting Started
    • ▶️Welcome Setup Guide
    • 🎉Thank you for your purchase!
    • 🔀Import Figma designs into Codelessly
    • 🖨️Publish your design as a website
  • ⚡Editor Basics
    • Start a New Project
    • Editor Tools
    • Creating Your First Layout
    • Using Components
    • Working with Size Fits
  • ⚡Advanced Editor Usage
    • Working with Variants
    • Using External Components
    • Size Fits Settings
  • ☁️Codelessly CloudUI™
    • 3-Minute Quick Start
    • Connecting Data
    • Calling Functions
  • Setting Up Custom Domains
    • Linking with Github Repository
    • Deploy on Netlify
    • Deploy on Vercel
Powered by GitBook
On this page
  • "Call Function" Action
  • Functions Field

Was this helpful?

  1. Codelessly CloudUI™

Calling Functions

Learn how to call custom functions in the SDK.

PreviousConnecting DataNextLinking with Github Repository

Last updated 1 year ago

Was this helpful?

"Call Function" Action

Actions are meant to make the UI more functional. Using actions, you can navigate to a different page, change state of a widget, launch URLs, etc. In this case, we need to call a custom function in the SDK. So, we use the Call Function action.

Head over to Develop Tab located in the app bar.

You should see the Actions Panel in the right. Now, select the node you wish to add the action to.

To add an action, tap on the add icon and select "Call Function Action" from the dropdown.

Next, tap on the settings icon to open the settings window.

Enter the custom function's name in the Function Name Field.

Action to call a custom function is now added to the node. Now, we need to provide the function in the SDK.

Functions Field

We can provide custom functions to the CodelesslyWidget using its functions parameter which is of type Map<String, CodelesslyFunction<T>>. Map's key is the name of the function and value is CodelesslyFunction class that takes in the function itself in its constructor.

CodelesslyFunction has a parameter call which is a function with generic return type T. Here's an example of how we can declare functions in the widget.

CodelesslyWidget(
  functions: {
    'expandForecastPage': CodelesslyFunction((context, ref, params) {...}),
  }
);

ref is an instance of CodelesslyContext that you may use to access data and other functions from the SDK.

params is a Map that contains any parameters passed by the function when it is called. These parameters can be defined on the function call from the Editor.

Now, node can access the function and call it on relevant trigger (click in this case).

☁️
Develop Tab
Node selected
Adding Call Function Action
Action Settings Window
Function Name Field