flekschas / svelte-simple-modal

A simple, small, and content-agnostic modal for Svelte v3 and v4
https://svelte.dev/repl/b95ce66b0ef34064a34afc5c0249f313
MIT License
422 stars 30 forks source link

Option to pass reactive props to modal without using a store? #79

Closed mhsdesign closed 2 years ago

mhsdesign commented 2 years ago

i have something like this: okay i my case something is an exported prop which takes in some reactive data...

the proplem is in the showPopup, something is assigned and looses its reactivity. is there a way to keep the reactivity without using stores?

let something = 1;

setInterval(() => {
  something++;
}, 1000)

const showPopup = () => {
  open(Popup, { message: something });
};
flekschas commented 2 years ago

Unfortunately, this is simply not possible. something is a number and passed in by value, which does not support any reactivity. In general, Svelte stores is what you would want to use in order to enable reactivity. What is the issue with using Svelte stores?

mhsdesign commented 2 years ago

issue that i will need to rethink a part of my state handling.

but i will go with a $tore - thanks