Skip to content

Type Alias: MountFn

API / @xmachines/play-dom / MountFn

type MountFn = (actor, container, options?) => Cleanup;

Defined in: packages/play-dom/src/create-play-ui.ts:94

The mount function that createPlayUI returns.

Call it with (actor, container, mountOptions?) to start the renderer. It returns a disconnect cleanup function. That function stops the render and clears the container.

The return is the release of the mount. A caller runs it, or a scope releases it:

const mount = createPlayUI(registryResult);
{
using stop = mount(actor, container);
// stop() runs at the end of the scope, and after an exception too
}

A Cleanup IS a () => void, so a caller that runs the release keeps that code. A consumer that WRITES a value of this type — a wrapper of a mount, or a stand-in for one — builds its release with asCleanup of @xmachines/play, which this package re-exports:

const mount: MountFn = (actor, container, options) => {
const stop = realMount(actor, container, options);
return asCleanup(() => stop());
};

Parameters

ParameterType
actorViewActor
containerHTMLElement
options?MountOptions

Returns

Cleanup