Documentation - xBeastMode/TaskAPI GitHub Wiki

Documentation

===

Terminate task

void terminateTask(string $task_name)
Parameter Type Description
$task_name string Task Indentifier

Description: Cancels and removes task from the task list. returns - void

Example:

\TaskAPI\Base::getInstance()->getTaskAPI()->terminateTask('your_task_name');
```



Kill Task
---

```PHP
void killTask(string $task_name)
```

| Parameter  | Type   | Description      |
| ---------  | ------ | ---------------- |
| `$task_name` | string | Task Indentifier |

Description: Cancels task<br>
return - void

Example: 
````PHP
\TaskAPI\Base::getInstance()->getTaskAPI()->cancelTask('your_task_name');
```

Resume Task
---

```PHP
void resumeTask(string $task_name)
```

| Parameter  | Type   | Description      |
| ---------  | ------ | ---------------- |
| `$task_name` | string | Task Indentifier |

Description: Resumes a task that has been paused<br>
returns - void

Example: 
````PHP
\TaskAPI\Base::getInstance()->getTaskAPI()->resumeTask('your_task_name');
```

Task Exists
---

```PHP
void taskExists(string $task_name)
```

| Parameter  | Type   | Description      |
| ---------  | ------ | ---------------- |
| `$task_name` | string | Task Indentifier |

Description: Check if task exists<br>
returns - void

Example: 
````PHP
\TaskAPI\Base::getInstance()->getTaskAPI()->taskExists('your_task_name');
```

Get Task
---

```PHP
void getTask(string $task_name)
```

| Parameter  | Type   | Description      |
| ---------  | ------ | ---------------- |
| `$task_name` | string | Task Indentifier |

Description: Gets an existing task<br>
returns - void

Example: 
````PHP
\TaskAPI\Base::getInstance()->getTaskAPI()->getTask('your_task_name');
```

Remove Task
---

```PHP
void removeTask(string $task_name)
```

| Parameter  | Type   | Description      |
| ---------  | ------ | ---------------- |
| `$task_name` | string | Task Indentifier |

Description: removes an existing task from the task list<br>
returns - void

Example: 
````PHP
\TaskAPI\Base::getInstance()->getTaskAPI()->removeTask('your_task_name');
```

Delayed Task
---

```PHP
void delayedTask(string $task_name, int $interval, $callback)
```

| Parameter  | Type   | Description      |
| ---------  | ------ | ---------------- |
| `$task_name` | string | Task Indentifier |
| `$interval`  | int    | Time to wait to run task in seconds|
| `$callback`  | array / string | your callback function |

Description: creates new delayed task (only runs once)<br>
returns - void

Example: 
````PHP
function callback(){
//your code to run here
}
\TaskAPI\Base::getInstance()->getTaskAPI()->delayedTask('your_task_name', 5, 'callback');//runs after 5 seconds
```

Repeating Task
---

```PHP
void repeatingTask(string $task_name, int $interval, $callback)
```

| Parameter  | Type   | Description      |
| ---------  | ------ | ---------------- |
| `$task_name` | string | Task Indentifier |
| `$interval`  | int    | Time to wait to run task in seconds|
| `$callback`  | array / string | your callback function |

Description: creates new delayed task (only runs once)<br>
returns - void

Example: 
````PHP
function callback(){
//your code to run here
}
\TaskAPI\Base::getInstance()->getTaskAPI()->repeatingTask('your_task_name', 5, 'callback');//runs every 5 seconds
```

Delayed Repeating Task
---

```PHP
void delayedRepeatingTask(string $task_name, $callback, int $delay, int $interval)
```

| Parameter  | Type   | Description      |
| ---------  | ------ | ---------------- |
| `$task_name` | string | Task Indentifier |
| `$callback`  | array / string | your callback function |
| `$delay`  | int    | Time to wait to start task in seconds |
| `$interval`  | int    | Time to wait to run task in seconds|

Description: creates new delayed repeating task <br>
returns - void

Example: 
````PHP
function callback(){
//your code to run here
}
\TaskAPI\Base::getInstance()->getTaskAPI()->delayedTask('your_task_name', 'callback', 5, 5);//runs after 5 seconds then runs every 5 seconds
```

Pause Task
---

```PHP
void pauseTask(string $task_name, int $seconds)
```

| Parameter  | Type   | Description      |
| ---------  | ------ | ---------------- |
| `$task_name` | string | Task Indentifier |
| `$seconds`  | int    | Time to pause the task in seconds |

Description: pauses task for specific amount of seconds<br>
returns - void

Example: 
````PHP
\TaskAPI\Base::getInstance()->getTaskAPI()->pauseTask('your_task_name', 5);//pause task for 5 seconds
```

End After
---

```PHP
void endAfter(string $task_name, int $seconds)
```

| Parameter  | Type   | Description      |
| ---------  | ------ | ---------------- |
| `$task_name` | string | Task Indentifier |
| `$seconds`  | int    | Time to wait to end task in seconds |

Description: ends task after specific amount of seconds<br>
returns - void

Example: 
````PHP
\TaskAPI\Base::getInstance()->getTaskAPI()->endAfter('your_task_name', 5);//ends task after 5 seconds
```