injectRequestClose
Asks the host to dismiss the view.
injectRequestClose(): RequestCloseFn
type RequestCloseFn = () => Promise<void>;
import { injectRequestClose } from "ng-mcp-ui/web";
export class PollWidget {
private readonly requestClose = injectRequestClose();
async done() {
await this.requestClose();
}
}
The call tears down the whole view. It is not the same as a close of a modal.
| You want | Use |
|---|---|
| Remove the view | injectRequestClose |
| Close a modal and keep the view | MCP_MODAL close() |
| Make the view smaller | injectDisplayMode with "inline" |
Write your state first
The view can go away as soon as the promise resolves. If you use
injectViewStore, its host writes are debounced, therefore a
pending write can be lost.
Call flush() first.
this.store.flush();
await this.requestClose();
Host support
Supported on the two host runtimes, through different host calls.
| Host | Call |
|---|---|
| Apps SDK | The close request of the host. |
| MCP Apps | The teardown request of the host. |