Homey.FlowArgument
const { FlowArgument } = require('homey');
Methods
registerAutocompleteListener(fn) → {FlowArgument}
Register a listener for a autocomplete event. Return a Promise, or run the callback.
This is fired when the argument is of type autocomplete
and the user typed a query.
Parameters:
Name |
Type |
Description |
fn |
function
|
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
|
callback |
function
|
Name |
Type |
Description |
err |
Error
|
|
result |
Array
|
An array of result objects
|
|
|
Example
const Homey = require('homey');
let myAction = new Homey.FlowCardAction('my_action');
myAction.register();
let myActionMyArg = myAction.getArgument('my_arg');
myActionMyArg.registerAutocompleteListener( ( query, args ) => {
let results = [
{
"id": "abcd",
"name": "My Value"
}
];
// filter for query
results = results.filter( result => {
return result.label.toLowerCase().indexOf( query.toLowerCase() ) > -1;
});
return Promise.resolve( results );
});