Closed woutdp closed 1 year ago
Tried it out and it's working but it gives a warning when providing an attribute that is not specifically defined.
code: https://github.com/woutdp/live_svelte/tree/nicer-prop-passing
If we can make the warning disappear somehow we can add it.
This is exactly what I've been asking you regarding props. Just saw this. This will be very useful enhancement.
I think this issue is useful, but also wanted to mention a third way of defining props.
What if you could do something like this in the mount:
{:ok, assign(socket, :svelte, %{number: 1})}
And then the prop number would be automatically picked up since we know that's what we want to pass
<LiveSvelte.render name="Example"/>
Actually we can probably even get away with the following:
{:ok, assign(socket, :number, 1)}
And make sure it's automatically picked up, but then we'd have to deprecate the previous way I think.
One thing is that let's say you have 2 Svelte components in one LiveView, you might only want to pass certain things to one of them and certain things to the other, don't know if it's really an issue though
Something to think about
That is better. I think the sigil will become the preferred method so whatever works with that will be my go to.
Will be closed by: https://github.com/woutdp/live_svelte/pull/50
Current:
New:
We can probably use
@rest
for this. We should still allowprops
as that can be a way to add keywords that are taken such as theclass
andname
keyword (or even theprops
keyword, which is very meta)