pateketrueke / yrv

Your routing vibes! (for Svelte)
https://svelte.dev/repl/0f07c6134b16432591a9a3a0095a80de
161 stars 9 forks source link

Implement option to cancel route change in yrv #88

Open Immo-Be opened 2 years ago

Immo-Be commented 2 years ago

Hey! :)

With react-router there is the prompt component that prevents a user to navigate to another page (e.g. when there are unsaved changes in a form). It would be nice to implement a functionality like that.

pateketrueke commented 2 years ago

Hi, it sounds like a nice feature, if it were already implemented how its DSL would look?

Immo-Be commented 2 years ago

I'd say a good implementation would be react-router where the user is prompted with a message when a certain state is entered. The prompt component is then rendered like:

<Prompt when={formIsHalfFilledOut} message="Are you sure you want to leave?" />

Ideally, message would accept not only a string but also a function

See here for more details