self

js/realm/self.ts

fino:realm/self - child Realm's own communication port.

Reactor-pooled realms expose the transport port installed by their bootstrap. Root and process realms return undefined.

Module caching guarantees a single port instance per context. Importing this module from both the entry module and the bootstrap always yields the same object.

import { port } from 'fino:realm/self';

port?.addEventListener('message', (event) => {
  port?.postMessage({ echo: event.data });
});
port?.start();

Constants

const port

Message port passed to this child realm, or undefined when none exists.

Reactor-pooled child realms receive the transport port installed by their bootstrap. Root, process, and remote realms return undefined.

import { port } from 'fino:realm/self';

port?.addEventListener('message', (event) => {
  port?.postMessage({ echo: event.data });
});
port?.start();