Can I schedule tasks for the future?
In Mechanic, the decision to schedule an event is an action all by itself – the "event" action. This means that the flow for scheduling looks like this:
- Task A is created, subscribing to a user event – for the sake of this example, we'll use "user/scheduler/future". This is the task that's intended to run in the future.
- Task B is created or configured to trigger that event ("user/scheduler/future"), using the "event" action, with the "run_at" option specifying exactly when that event should be run.
- Task B is triggered, which runs the aforementioned "event" action. This results in a "user/scheduler/future" event being scheduled for the future, which will cause Task B to be run at that time.
Tip: You can easily schedule recurring tasks, by subscribing to Mechanic's scheduler events. And all event subscriptions can be combined with a delay, as in mechanic/scheduler/daily+6.hours.
Here's an example of how the "event" action might be written:
{% action "event" %} { "topic": "user/scheduler/future", "data": "this is a future event!", "run_at": "October 10" } {% endaction %}
The "run_at" option accepts many datetime formats, including ISO 8601 values, and UNIX timestamps. To ensure that it's reading your value correctly, use the task preview pane on the right:
