function / @typed/ui/Dialog

requestClose

Requests the native dialog close lifecycle, including its cancel event.

Learn this UI primitive →

Package version
1.0.0-beta.7
Category
Cancelable dismissal
Since
1.0.0

Import

import { requestClose } from "@typed/ui/Dialog";

Signatures

export declare function requestClose(state: RefSubject.HydratedRefSubject<State, Schema.SchemaError>, returnValue?: string): Effect.Effect<void>;

Why

The browser’s requestClose() is cancelable. The fallback dispatches a real cancelable cancel event and calls close() only when it is accepted, so user handlers retain the same veto point.

Ownership and lifetime

The Effect consults the dialog currently registered for the hydrated state; registration is removed when Content’s Scope closes. No dialog is retained after that finalizer.

Examples

import { Effect } from "effect"
import * as Dialog from "@typed/ui/Dialog"

const program = Effect.gen(function* () {
  const state = yield* Dialog.makeState({ open: true })
  yield* Dialog.requestClose(state)
})

Other public imports

These import paths expose the same declaration. Each page retains its own public name and signature.

Source