svelte-toasts
svelte-toasts copied to clipboard
Duplicate Keys
Since the UID of a toast is generated via Date.now() generating two toasts quickly after one another causes svelte to throw: Error: Cannot have duplicate keys in a keyed each. I fixed it in my fork by generating the UID using Math.random() which should reduce the collision rate, although I'm not sure if that's how you'd like to fix it.

Math.random isn't guaranteed unique either. It seems like a simple counter would be plenty for this.
let last_toast = 0;
function add_toast(...) {
while (last_toast == Date.now()) {}
last_toast = Date.now();
toasts.add({...});
}
I think it should check if a uid is passed before overwriting it I tried passing a uid but it's not taken into account
I think we should use a global counter
I create PR for this, using key instead of uid, auto-generated uuid.v4() or given input