ciscoheat / sveltekit-flash-message

Send temporary data after redirect, usually from endpoints. Works with both SSR and client.
https://www.npmjs.com/package/sveltekit-flash-message
MIT License
246 stars 5 forks source link

Suggestion: improve `getFlash` options #35

Closed Ennoriel closed 4 months ago

Ennoriel commented 4 months ago

I am using this library with sveltekit-superforms and without svelte-french-toast.

I'd like to be able to say from the server of my app if the notification is a success, a warning or an error. In case of a success and warning, I'd like the toast to disappear after 6 and 8 seconds while I don't want the errors to disappear by themselves.

In other words, I'd like to configure options based on the flash message.

This could me achieved with options being a configuration object or a function with the following signature (flash: App.PageData['flash']): Partial<FlashOptions>.

ciscoheat commented 4 months ago

The options are a bit complicated, being tied to specific routes and below, so I'm afraid I cannot do that easily. I think you can handle this case with a reactive statement though, doing a setTimeout that sets the store to undefined depending on status..