# once

```ts
function once<T extends EventTarget, K extends EventList<T> | (string & {})>(target: T, name: K): Operation<EventTypeFromEventTarget<T, K>>
```

Create an [Operation](https://frontside.com/effection/api/v4-next/Operation.md) that yields the next event to be emitted by an
[EventTarget](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget).

### Examples
#### Example 1
```ts
// wait for connection establishment before proceeding
yield* once(socket, "open");
```

---
### Type Parameters
T extends EventTarget


K extends EventList&lt;T&gt; | string &amp; &#123;&#125;


### Parameters


**target**: T


the event target to be watched


**name**: K


the name of the event to watch. E.g. "click"
### Return Type


[Operation](https://frontside.com/effection/api/v4-next/Operation.md)&lt;EventTypeFromEventTarget&lt;T, K&gt;&gt;


an Operation that yields the next emitted event

[View code](https://github.com/thefrontside/effection/tree/effection-v4.2.0/lib/events.ts#L38)
