Question:
What I’m trying to do here may not be possible, but as a newcomer to Svelte, I hope it is. ๐I have a delete button in a component that opens a globally available modal that serves as a confirmation dialog. The modal component is in my
__layout.svelte
so I can invoke it from anywhere in my app.modal
store:confirmTrash
function to pass the user’s response in the modal back to where the modal was invoked. Is this possible?Answer:
For this to work, you just have to pass in function and call it accordingly.I would not use singleton component like this but create new instances using the client-side component API. It is less redundant, leads to a cleaner life cycle and less unnecessary global state.
Example of that:
If you have better answer, please add a comment about this, thank you!