---
title: "Wait Decorator"
description: "The @wait decorator defers a method until a given condition function returns true, useful for delaying calls until a dependency like jQuery has loaded."
metadata:
  - name: keywords
    content: "jodit wait, decorator, condition, deferred call, dependency, async"
---
# @wait

Wrap function in wait wrapper, it will be called after `condition` returns `true`

```typescript
import { component, wait } from 'jodit/core/decorators';
import { UIElement } from 'jodit/ui';

@component
class UISomeElement extends UIElement {
  @wait(() => typeof jQuery !== 'undefined')
  protected runOnLoadJQuery(html: string): void {
    jQuery(this.container).html(html);
    alert('Run');
  }
}

const elm = new UISomeElement(jodit);
elm.runOnLoadJQuery('<h1>One</h1>'); // Do nothing
// jQuery is loaded
// alert
```


#### Call Signature

**wait**\<`T`\>(`condition`): [`Function`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function)

Defined in: [src/core/decorators/wait/wait.ts:18](https://github.com/xdan/jodit/blob/main/src/core/decorators/wait/wait.ts#L18)

##### Type Parameters

| Type Parameter |
| ------ |
| `T` *extends* [`IViewBased`](../interfaces/types.IViewBased.html)\<[`IViewOptions`](../interfaces/types.IViewOptions.html)\> |

##### Parameters

| Parameter | Type |
| ------ | ------ |
| `condition` | (`ctx`) => `boolean` |

##### Returns

[`Function`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function)

#### Call Signature

**wait**\<`T`\>(`condition`): [`Function`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function)

Defined in: [src/core/decorators/wait/wait.ts:21](https://github.com/xdan/jodit/blob/main/src/core/decorators/wait/wait.ts#L21)

##### Type Parameters

| Type Parameter |
| ------ |
| `T` *extends* [`IViewComponent`](../interfaces/types.IViewComponent.html)\<[`IViewBased`](../interfaces/types.IViewBased.html)\<[`IViewOptions`](../interfaces/types.IViewOptions.html)\>\> |

##### Parameters

| Parameter | Type |
| ------ | ------ |
| `condition` | (`ctx`) => `boolean` |

##### Returns

[`Function`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function)
