# FJsMacros.EventAndContext

`com.jsmacrosce.jsmacros.core.library.impl.FJsMacros.EventAndContext`

Pairs an event received by `waitForEvent` with its event container.  
 ```js
const next = JsMacros.waitForEvent("Tick");  
try {
  Chat.log(next.event.getEventName());  
} finally {
  next.context.releaseLock();  
}
 ```

 Release the context lock promptly after processing when the returned event is held; the result is not necessarily currently locked.

## Type Parameters

- `E`: paired event type

Nested type declared in [JsMacros](FJsMacros.md); not a separate global library.

## Constructors

### new FJsMacros.EventAndContext {#com.jsmacrosce.jsmacros.core.library.impl.FJsMacros.EventAndContext_constructor-E-EventContainer-}

```js
new FJsMacros.EventAndContext(E extends BaseEvent event, EventContainer<?> context)
```

Stores the supplied event and container references without dispatching or changing lock state.

**Parameters:**
- `event`: event to pair
- `context`: paired event container; supply a non-null reference for `toString()`

## Fields

### context {#com.jsmacrosce.jsmacros.core.library.impl.FJsMacros.EventAndContext_context}

```js
context: EventContainer<?>
```

The event container paired with `event`; release its lock promptly when processing a held event.

### event {#com.jsmacrosce.jsmacros.core.library.impl.FJsMacros.EventAndContext_event}

```js
event: E extends BaseEvent
```

The event reference paired with `context`; it is not copied or frozen.

## Methods

### toString {#com.jsmacrosce.jsmacros.core.library.impl.FJsMacros.EventAndContext_toString-}

```js
toString(): String
```

Formats both stored references as `EventAndContext:{"event": %s, "context": %s}` using their `toString()` results; this is diagnostic text, not JSON or a snapshot.

**Returns:** diagnostic string containing the event and container representations
