FlowArgument

The FlowArgument class represents an argument for a Flow Card as defined in the app's app.json. This class must not be initiated by the developer, but retrieved by calling FlowCard#getArgument.

Table of Contents

Methods

registerAutocompleteListener(listener) → {FlowArgument}

Register a listener for a autocomplete event. This is fired when the argument is of type autocomplete and the user typed a query.

Parameters:
Name Type Description
listener function

Should return a promise that resolves to the autocomplete results.

Name Type Description
query string

The typed query by the user

args object

The current state of the arguments, as selected by the user in the front-end

Returns:
Type:
FlowArgument
Example
let myAction = this.homey.flow.getActionCard('my_action');

let myActionMyArg = myAction.getArgument('my_arg');

myActionMyArg.registerAutocompleteListener(async (query, args) => {
  let results = [
    { id: 'abcd', name: 'My Value' },
  ];

  // filter for query
  results = results.filter((result) => {
    return result.label.toLowerCase().includes(query.toLowerCase());
  });

  return results;
});