Actions

Actions are the work-house of an Automation. They execute the resulting business logic as set-up by the user.

Booting

Much like Actions, they are able to asynchronously boot before being ready to execute.

export default class extends window.casthub.card.action {
    async mounted(): Promise<void> {
        await super.mounted();

        // Establish a WebSocket connection, start long-polling, etc.
    }
}
module.exports = class extends window.casthub.card.action {
    async mounted() {
        await super.mounted();

        // Establish a WebSocket connection, start long-polling, etc.
    }
};

Execution

When a Trigger is executed in an Automation and all Conditions pass, Actions will be executed together (Or asynchronously if the User enables Sequential Actions). A function inside the Action will be called to execute the logic, run. It accepts a single parameter, input, which is the data output from the Trigger that executed the Automation.

Each Trigger can define it's own I/O schema, as such, it's better to test or hard-encode certain services/systems your Action works with if you rely on the given input.

import { CardIO } from '@casthub/types';

export default class extends window.casthub.card.action {
    async run(input: CardIO): Promise<void> {
        // Do something!
    }
}
module.exports = class extends window.casthub.card.action {
    async run(input) {
        // Do something!
    }
};