I'm making a modal, with its attributes stored in a store. Rather than open it like this, from an element: on:click={() => $modal.isOpen = true}
I want to open it like this:
on:click={() => $modal.toggle()}
from an element.
Here is my code:
export const modal = writable({
isOpen: false,
title: 'Title',
content: 'Content',
toggle: () => {
console.log(modal)
modal.set({ ...modal, isOpen: true });
}
});
When I log modal
, it logs just the set, subscribe, update
methods. Then when I click again, those methods are gone: it properly overwrites them, it just seems that I can never get the modal's initialized state. I've tried to access the current object with this
or parameters ((a, b) =>
) but neither return anything.