Flow / 06. Triggers
Updated: 18. January 2018
Author: Peter Širka

07. Triggers

An trigger can execute an action on the server-side which can return some data asynchronous. Triggers are the only one way for obtaining some code-lists from server-side.

Server-side

// Register a trigger
FLOW.trigger('name', function(next, data) {    

    // Data sent from client-side
    console.log(data);

    // Sends back some data
    next([1, 2, 3, 4]);

});

// Unregister a trigger
FLOW.trigger('name', null);

Client-side

Trigger can be used in the Settings form of specific component.

// TRIGGER(trigger_name, [data], callback(data))

// Call the trigger
TRIGGER('name', function(data) {
    console.log(data); // outputs [1, 2, 3, 4]
});

TRIGGER('name', 'path.to.bind.response');
// Binds the response to: window.path.to.bind.response === [1, 2, 3, 4]

Learn from existing components

Learn from some components which use trigger functionality: