# Class TaskLooper

Run a task in a fixed period loop.

#### Hierarchy

- TaskLooper

- Defined in src/utils/TaskLooper.ts:21

#####
Index

### Constructors

constructor

### Properties

_fn
_isLooping
_isStarted
_timeout

### Methods

_runLoop
start
stop

## Constructors

### constructor

- new TaskLooper(fn: (() => Promise<void>)): TaskLooper

- Build the looper with a function to invoke on a fixed period loop.

  #### Parameters

  - ##### fn: (() => Promise<void>)

    the async function to invoke

    - - (): Promise<void>

      - #### Returns Promise<void>

  #### Returns TaskLooper

  - Defined in src/utils/TaskLooper.ts:33

## Properties

### _fn

_fn: (() => Promise<void>)

#### Type declaration

- - (): Promise<void>

  - #### Returns Promise<void>

- Defined in src/utils/TaskLooper.ts:23

### _isLooping

_isLooping: boolean

- Defined in src/utils/TaskLooper.ts:25

### _isStarted

_isStarted: boolean

- Defined in src/utils/TaskLooper.ts:24

### _timeout

_timeout: undefined | Timeout

- Defined in src/utils/TaskLooper.ts:26

## Methods

### _runLoop

- _runLoop(periodInMs: number, targetFixedPeriod: boolean): Promise<void>

- #### Parameters

  - ##### periodInMs: number

  - ##### targetFixedPeriod: boolean

  #### Returns Promise<void>

  - Defined in src/utils/TaskLooper.ts:63

### start

- start(periodInMs: number, targetFixedPeriod: boolean): void

- Start the task loop.

  ### Returns

  this instance for chaining

  #### Parameters

  - ##### periodInMs: number

    the loop period in milliseconds

  - ##### targetFixedPeriod: boolean

    specifies if the task should target a fixed period by accounting for run time (default false)

  #### Returns void

  - Defined in src/utils/TaskLooper.ts:46

### stop

- stop(): void

- Stop the task loop.

  #### Returns void

  - Defined in src/utils/TaskLooper.ts:56

Generated using TypeDoc