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
271 stars 6 forks source link

Remove on click #44

Open benquan opened 2 months ago

benquan commented 2 months ago

Is there an option to remove the flash message when I click on it? Or is there an easy way to do it?

I have ser a long time for the messages, but would like the option to remove them if I click on it.

Thanks

Ben

ciscoheat commented 2 months ago

It's very simple, just set the flash store to undefined in a click handler:

import { getFlash } from 'sveltekit-flash-message';
import { page } from '$app/stores';

const flash = getFlash(page);
$flash = undefined;