svelte-modals
svelte-modals copied to clipboard
Add `option.onClose` for `openModal` fn.
I think adding a close handler to openModal
fn could make the componet very flexible.
Imagine a scenario like this:
const confirmModal = ({question}) => new Promise(resolve =>
openModal(ConfirmModal, onConfirm: () => resolve(true), { onClose: () => resolve(false) })
);
const isConfirmed = await confirmModal({question: "Are you sure?"});
OFC I can add an event handler to Cancel
button or corner X
button, but what about closing stuff programmatically from another place (eg. by clicking backdrop)?