Would you like to contribute to the Titanium docs? To get started, sign up for an account on the Appcelerator Wiki and sign our CLA.

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Made a format change

...

Property

Description

Required

Type

name

The name of the Codeblock

yes

string

description

The description of the Codeblock

yes

string

path

The relative path to the function to be invoked.

yes

string

Metadata example

 

Code Block
{
  "name": "Greet",
  "description": "Some codeblock to run with Greet flow",
  "path": "Greet.js"
}

Functionality

The functional part of a Codeblock should be a .js file which exports a function of the following signature:

...

Note

Most of the time errors should be returned in the callback as a standard response. Using the first parameter to return errors is the same as throwing an error in the Codeblock and should rarely need to be used.

Functionality example

 

Code Block
linenumberstrue
languagejs
function invoke(arrow, params, cb) {
    const salutation = arrow.config.helloworld.salutation;
    if (!params.username) {
        return cb(null, {
            error: 'Invalid name'
        });
    }
    const body = salutation + ' ' + params.username;
    cb(null, body);
}
exports = module.exports = invoke