Skip to content

Commit 3d8c3ba

Browse files
committed
Add time based logic docs
1 parent 8dac645 commit 3d8c3ba

File tree

8 files changed

+166
-3
lines changed

8 files changed

+166
-3
lines changed
184 KB
Loading
135 KB
Loading
88.4 KB
Loading
182 KB
Loading

docs/resources/control-flow/time-based-logic/overview.md

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
title: Periodic [Action]
3+
sidebar_position: 3
4+
---
5+
6+
# Periodic Action
7+
8+
Periodic execution of logic refers to running a specific block of code or a set of actions at
9+
regular, defined intervals. This is useful for tasks that need to be repeated continuously or at
10+
specific time intervals.
11+
12+
## Use-cases
13+
14+
- For tasks that need regular updates, such as fetching data from a server, monitoring system
15+
health, or updating a user interface.
16+
- In scenarios where periodic checks or maintenance tasks are required (e.g., cleaning up
17+
temporary files, sending periodic notifications).
18+
- Implementing polling mechanisms for checking changes in state or data.
19+
20+
## Start Periodic Action
21+
22+
To create a periodic action workflow, add the **Start Periodic Action** action either on the **On
23+
Page Load** action trigger of your page or on any widget that should start the periodic action.
24+
25+
The properties of the Periodic Action look like this:
26+
27+
![periodic-action.png](imgs%2Fperiodic-action.png)
28+
29+
## Stop Periodic Action
30+
31+
You can call the **Stop Periodic Action** action from anywhere on the page or component to stop
32+
one or multiple
33+
periodic actions.
34+
35+
:::danger[Dont forget to stop the Periodic Actions]
36+
Stopping a periodic action is crucial to prevent unnecessary resource consumption and potential
37+
performance issues. It ensures that tasks do not continue running in the background when they are no
38+
longer needed, which can help maintain the efficiency and responsiveness of your application.
39+
:::
40+
41+
### Periodic Action vs Timer
42+
43+
| Feature | Timer Widget | Periodic Action |
44+
|-------------|-----------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------|
45+
| **Purpose** | Used for single or non-repetitive timing events, often within user interfaces. | Used for repetitive tasks that need to run at regular intervals. |
46+
| **Usage** | To set a countdown timer, start/stop actions based on user input, or trigger actions after a specific duration. | For background tasks, monitoring, regular updates, and periodic checks. |
47+
| **Example** | Countdown timer in a quiz application. | Fetching new messages from a server every 5 minutes. |
48+
49+
50+
### Periodic Actions vs Loops
51+
52+
| Feature | Periodic Actions | Loops |
53+
|---------------------------|-----------------------------------------------------------------------------|------------------------------------------------------------------------|
54+
| **Purpose** | To execute a task at regular, defined intervals. | To execute a task repeatedly until a condition is met. |
55+
| **Execution Frequency** | Executes at specified time intervals (e.g., every 60 seconds). | Executes continuously until the loop condition is false. |
56+
| **Use Case** | Suitable for tasks needing regular updates, such as fetching new data. | Suitable for tasks requiring iteration over collections or repeated checks. |
57+
| **Control** | Can be started and stopped easily, allowing for controlled execution. | Runs until a break condition is met or the loop is explicitly stopped. |
58+
| **Resource Management** | Efficient, as it allows idle time between executions. | Can be resource-intensive if not managed properly, as it runs continuously. |
59+
| **Examples** | Fetching new offers from a server every 5 minutes. | Iterating over a list of items to process them one by one. |
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
title: Timer [Widget]
3+
sidebar_position: 2
4+
---
5+
6+
**Timer [Widget]** allows developers to create countdown or count-up timers within your page. It is
7+
particularly useful in scenarios where timing is crucial, such as quizzes, auctions, workout apps,
8+
and various time-sensitive activities.
9+
10+
## Use Cases
11+
12+
- **Quizzes and Exams:** Enforcing time limits for answering questions.
13+
- **Auctions:** Displaying the remaining time for bids.
14+
- **Workouts:** Timing exercises and rest periods.
15+
- **Events:** Counting down to the start or end of an event.
16+
- **Productivity:** Using Pomodoro timers to manage work sessions and breaks.
17+
18+
## Timer Types
19+
20+
- **Countdown Timer:** Counts down from a specified time to zero, often used in scenarios where a
21+
task or event needs to be completed within a set period.
22+
23+
- **Count-up Timer:** Counts up from zero to a specified time or indefinitely, useful for tracking
24+
the duration of an event or activity.
25+
26+
On adding the Timer widget to your page, you can specify the type of timer and other properties
27+
as mentioned here:
28+
29+
![timer-widget.png](imgs%2Ftimer-widget.png)
30+
31+
## On Timer End [Action Trigger]
32+
33+
You can also specify a flow of actions when the timer ends. You can find this Action Trigger on
34+
clicking the Action Flow Editor on the Timer widget.
35+
36+
![timer-widget-action.png](imgs%2Ftimer-widget-action.png)
37+
38+
## Controlling the Timer
39+
40+
You can control the timer from anywhere on the page. Using any widget's Action Flow Editor, you can perform the following actions:
41+
42+
- **Start Timer:** This starts the timer. If the timer is already started, triggering this type
43+
won't
44+
have any effect.
45+
46+
- **Stop Timer:** This stops the timer. This will have effect only if the timer is started.
47+
48+
- **Reset Timer:** This resets the timer and brings it to the initial state.
49+
50+
![timer-control.png](imgs%2Ftimer-control.png)
51+
52+
## Periodic Action vs Timer
53+
54+
| Feature | Timer Widget | Periodic Action |
55+
|--------------------|----------------------------------------------------------------------------------------------------|-------------------------------------------------------------------|
56+
| **Purpose** | Used for single or non-repetitive timing events, often within user interfaces. | Used for repetitive tasks that need to run at regular intervals. |
57+
| **Usage** | To set a countdown timer, start/stop actions based on user input, or trigger actions after a specific duration. | For background tasks, monitoring, regular updates, and periodic checks. |
58+
| **Example** | Countdown timer in a quiz application. | Fetching new messages from a server every 5 minutes. |
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
title: Wait [Action]
3+
sidebar_position: 1
4+
---
5+
6+
# Wait [Action]
7+
8+
**"Waiting"** on an action or function is a fundamental concept in time-based logic, allowing developers to introduce intentional pauses within a sequence of actions. This is also known as delaying execution of logic, where the execution of a sequence of actions is paused for a specified period. This action is particularly useful when there is a need to synchronize events, manage the timing of operations, or ensure that certain conditions are met before proceeding further in a workflow.
9+
10+
## Delayed Execution of Logic
11+
Delaying execution of logic involves pausing the execution of a sequence of actions for a specified period. This is useful when you need to introduce a time delay before proceeding to the next step in a workflow or process.
12+
13+
## Use-cases
14+
15+
- When you need to wait for a certain condition to be met (e.g., waiting for data to load or a
16+
user to complete an action).
17+
- To create pauses between actions for better user experience (e.g., displaying messages
18+
sequentially).
19+
- Waiting before performing an animation.
20+
21+
## How to?
22+
23+
To implement a Wait Action in your Action Flows, follow this simple tutorial:
24+
25+
<div style={{
26+
position: 'relative',
27+
paddingBottom: 'calc(56.67989417989418% + 41px)', // Keeps the aspect ratio and additional padding
28+
height: 0,
29+
width: '100%'
30+
}}>
31+
<iframe
32+
src="https://demo.arcade.software/ou0tecrBVViOqy74U9nE?embed&show_copy_link=true"
33+
title=""
34+
style={{
35+
position: 'absolute',
36+
top: 0,
37+
left: 0,
38+
width: '100%',
39+
height: '100%',
40+
colorScheme: 'light'
41+
}}
42+
frameborder="0"
43+
loading="lazy"
44+
webkitAllowFullScreen
45+
mozAllowFullScreen
46+
allowFullScreen
47+
allow="clipboard-write">
48+
</iframe>
49+
</div>

0 commit comments

Comments
 (0)