---
url: 'https://adk.nht.io/api/@nhtio/adk/batteries/interfaces/PortLike.md'
description: >-
  The minimal message-passing duck the wire protocol (`protocol.ts`) is built
  over. A `Worker` / `MessagePort` (`post` = `postMessage`, `onMessage` wraps
  `addEventListener('message', ...)`) and a Node `ChildProcess` / `process`
  (`post` = `.send`, `onMessage` wraps `.on('message', ...)`) both satisfy this
  structurally — WP1 exercises it only against linked in-memory fake ports;
  WP2/WP3 wire it to the real transports.
---

# Interface: PortLike

Defined in: [src/batteries/isolation/types.ts:313](https://github.com/NHTIO/ADK/blob/v1.20260713.1/src/src/batteries/isolation/types.ts#L313)

The minimal message-passing duck the wire protocol (`protocol.ts`) is built over. A `Worker` /
`MessagePort` (`post` = `postMessage`, `onMessage` wraps `addEventListener('message', ...)`) and a
Node `ChildProcess` / `process` (`post` = `.send`, `onMessage` wraps `.on('message', ...)`) both
satisfy this structurally — WP1 exercises it only against linked in-memory fake ports; WP2/WP3 wire
it to the real transports.

## Methods

### onMessage()

```ts
onMessage(fn: (msg: unknown) => void): () => void;
```

Defined in: [src/batteries/isolation/types.ts:317](https://github.com/NHTIO/ADK/blob/v1.20260713.1/src/src/batteries/isolation/types.ts#L317)

Subscribe to inbound messages. Returns an unsubscribe function.

#### Parameters

| Parameter | Type                         |
| --------- | ---------------------------- |
| `fn`      | (`msg`: `unknown`) => `void` |

#### Returns

() => `void`

***

### post()

```ts
post(msg: unknown): void;
```

Defined in: [src/batteries/isolation/types.ts:315](https://github.com/NHTIO/ADK/blob/v1.20260713.1/src/src/batteries/isolation/types.ts#L315)

Send a message across the port. Fire-and-forget — no delivery confirmation at this layer.

#### Parameters

| Parameter | Type      |
| --------- | --------- |
| `msg`     | `unknown` |

#### Returns

`void`
