# Custom

`com.jsmacrosce.jsmacros.core.event.impl.EventCustom`

**Since:** 1.2.8

**Cancellable:** Per instance. Whether this event can be cancelled depends on the instance; check the fields below.

A named event with key-value arguments. Call [registerEvent()](#com.jsmacrosce.jsmacros.core.event.impl.EventCustom_registerEvent-) before subscribing; dispatch
 also reaches eligible `ANYTHING` listeners. Set `cancelable` before dispatch to let
 listeners cancel this instance; check [isCanceled()](../../../../../../../classes/com/jsmacrosce/jsmacros/core/event/BaseEvent.md#com.jsmacrosce.jsmacros.core.event.BaseEvent_isCanceled-) after dispatch returns. Set
 `joinable` before dispatch to let `trigger()` wait for listeners that asked to be
 awaited. Arguments may be changed before dispatch, by the creator between dispatches, or from a
 joined listener; a non-joined listener must treat them as read-only.

## Constructors

### new EventCustom {#com.jsmacrosce.jsmacros.core.event.impl.EventCustom_constructor-Core-String-}

```js
new EventCustom(Core<?, ?> runner, String eventName)
```

**Parameters:**
- `runner`: core that supplies this event's runtime context
- `eventName`: name used to dispatch this event

## Fields

### cancelable {#com.jsmacrosce.jsmacros.core.event.impl.EventCustom_cancelable}

```js
cancelable: boolean
```

Whether this event permits cancellation; defaults to `false`.

### eventName {#com.jsmacrosce.jsmacros.core.event.impl.EventCustom_eventName}

```js
eventName: String
```

Name used as this custom event's dispatch and subscription-registration key. Changing it does not register the new name; call [registerEvent()](#com.jsmacrosce.jsmacros.core.event.impl.EventCustom_registerEvent-) separately.

### joinable {#com.jsmacrosce.jsmacros.core.event.impl.EventCustom_joinable}

```js
joinable: boolean
```

Whether `trigger()` may wait for listeners that requested joined handling; defaults to
 `false`. Set it on the instance that calls `trigger()`; instances created for the
 same name do not share it. Setting `cancelable` also permits joining. The wait ends when a
 joined listener releases its event lock, normally on callback return.

## Methods

### cancellable {#com.jsmacrosce.jsmacros.core.event.impl.EventCustom_cancellable-}

```js
cancellable(): boolean
```

Whether this event currently permits cancellation.

**Returns:** the current value of `cancelable`; calling [cancel()](../../../../../../../classes/com/jsmacrosce/jsmacros/core/event/BaseEvent.md#com.jsmacrosce.jsmacros.core.event.BaseEvent_cancel-) marks this instance cancelled when permitted.

### getBoolean {#com.jsmacrosce.jsmacros.core.event.impl.EventCustom_getBoolean-String-}

```js
getBoolean(String name): Boolean
```

Returns the argument if it is a boolean; otherwise returns `null`.

**Parameters:**
- `name`: argument key

**Returns:** the value, or `null` if absent or not a boolean

**Since:** 1.2.8

### getDouble {#com.jsmacrosce.jsmacros.core.event.impl.EventCustom_getDouble-String-}

```js
getDouble(String name): Double
```

Returns the argument if it is a double; otherwise returns `null`.

**Parameters:**
- `name`: argument key

**Returns:** the value, or `null` if absent or not a double

**Since:** 1.2.8

### getInt {#com.jsmacrosce.jsmacros.core.event.impl.EventCustom_getInt-String-}

```js
getInt(String name): Integer
```

Returns the argument if it is an integer; otherwise returns `null`.

**Parameters:**
- `name`: argument key

**Returns:** the value, or `null` if absent or not an integer

**Since:** 1.2.8

### getObject {#com.jsmacrosce.jsmacros.core.event.impl.EventCustom_getObject-String-}

```js
getObject(String name): Object
```

Returns the argument value, or `null` if absent.

**Parameters:**
- `name`: argument key

**Returns:** the value, or `null` if absent

**Since:** 1.2.8

### getString {#com.jsmacrosce.jsmacros.core.event.impl.EventCustom_getString-String-}

```js
getString(String name): String
```

Returns the argument if it is a string; otherwise returns `null`.

**Parameters:**
- `name`: argument key

**Returns:** the value, or `null` if absent or not a string

**Since:** 1.2.8

### getType {#com.jsmacrosce.jsmacros.core.event.impl.EventCustom_getType-String-}

```js
getType(String name): String
```

Returns the stored argument's type label, or `null` when the key is absent.

**Parameters:**
- `name`: argument key

**Returns:** `Int`, `String`, `Double`, `Boolean`, or `Object`; `null` if absent

**Since:** 1.2.8

### getUnderlyingMap {#com.jsmacrosce.jsmacros.core.event.impl.EventCustom_getUnderlyingMap-}

```js
getUnderlyingMap(): Map<String, Object>
```

Returns a live view of the argument map. The creator and a joined delivery may change it;  
 a non-joined or already released delivery receives an unmodifiable view. A retained view
 stays live for reads, but writes through it (including entries and iterators) are checked
 when they happen and throw after the delivery can no longer change the event.

**Returns:** a live map view, or an unmodifiable view when this delivery cannot change the event

**Since:** 1.6.4

### joinable {#com.jsmacrosce.jsmacros.core.event.impl.EventCustom_joinable-}

```js
joinable(): boolean
```

Whether this event permits joining, based on its current `joinable` or `cancelable` flag.

**Returns:** `true` if either flag is true; this does not guarantee every listener is joined.

### putBoolean {#com.jsmacrosce.jsmacros.core.event.impl.EventCustom_putBoolean-String-boolean-}

```js
putBoolean(String name, boolean b): boolean
```

Stores a boolean argument.

**Parameters:**
- `name`: argument key
- `b`: value to store

**Returns:** the stored boolean value

**Since:** 1.2.8

### putDouble {#com.jsmacrosce.jsmacros.core.event.impl.EventCustom_putDouble-String-double-}

```js
putDouble(String name, double d): double
```

Stores a double argument.

**Parameters:**
- `name`: argument key
- `d`: value to store

**Returns:** the stored double value

**Since:** 1.2.8

### putInt {#com.jsmacrosce.jsmacros.core.event.impl.EventCustom_putInt-String-int-}

```js
putInt(String name, int i): int
```

Stores an integer argument.

**Parameters:**
- `name`: argument key
- `i`: value to store

**Returns:** the stored integer value

**Since:** 1.2.8

### putObject {#com.jsmacrosce.jsmacros.core.event.impl.EventCustom_putObject-String-Object-}

```js
putObject(String name, Object o): Object
```

Stores an object argument. Guest-language objects cause an [AssertionError](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/AssertionError.html).

**Parameters:**
- `name`: argument key
- `o`: value to store

**Returns:** the stored object

**Since:** 1.2.8

### putString {#com.jsmacrosce.jsmacros.core.event.impl.EventCustom_putString-String-String-}

```js
putString(String name, String str): String
```

Stores a string argument.

**Parameters:**
- `name`: argument key
- `str`: value to store

**Returns:** the stored string value

**Since:** 1.2.8

### registerEvent {#com.jsmacrosce.jsmacros.core.event.impl.EventCustom_registerEvent-}

```js
registerEvent(): void
```

Registers this event's name so it can be subscribed to and shown in the GUI.

**Since:** 1.3.0

### trigger {#com.jsmacrosce.jsmacros.core.event.impl.EventCustom_trigger-}

```js
trigger(): void
```

Dispatches this event to listeners registered under its name and eligible `ANYTHING`
 listeners. If `joinable()` is true, waits for listeners that requested joined handling.  
 The wait ends when each joined listener releases its event lock, normally on callback return.

**Since:** 1.2.8

### triggerAsync {#com.jsmacrosce.jsmacros.core.event.impl.EventCustom_triggerAsync-MethodWrapper-}

```js
triggerAsync(MethodWrapper<Object, Object, Object, ?> callback): void
```

Dispatches the event on a thread-pool task and returns without waiting. `callback` runs
 after dispatch returns; that does not mean every listener has finished unless dispatch joined it.

**Parameters:**
- `callback`: callback to run after dispatch returns

**Since:** 1.9.0
