← 所有消息

A confirmation the server can send on its own

DOM/toasts and DOM/dialog give a route two more things it can say. Load them and apply() gains toast: and alert:.

route async POST save {
    $this->store()
    return apply(toast: 'Saved.', inner: ['#list' => $this->list])
}

The value is in what is not there. No client-side notification library, no state to hold, no event to publish and subscribe to. The route that did the work is the thing that knows it succeeded, and it says so in the same response that updates the page.

That matters most for the cases where a toast is the only feedback. A background job that finishes, a websocket cast that arrives from another user's action, a validation that passed quietly. In each of those the alternative is a piece of client code whose entire job is to turn a flag into a message, and every one of them is a place where the flag and the message can disagree.

alert: is the blocking sibling for the moments that deserve interruption, rendered as a real dialog rather than the browser's own, so it looks like the rest of the application and does not freeze the page behind it.

Both are deliberately small. Anything more elaborate is layout, and layout belongs in a view where you can see it.

Engine 1.0. See toasts and dialog in the manual.

我们使用必要的cookie来使该网站正常工作。在您的许可下,我们还使用分析工具来改善网站。