You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I feel like I've seen a multi-setter like this somewhere (Laminext perhaps?) but can't find it right now.
One complication is that such an API should support mixing different kinds of keys (attrs, props, style props). Style props accept V | String, not just V, unlike other types of props, so would need special handling.
Ideally we would design an API that keeps a localized "map" of keys and values (e.g. (svg.x1 -> v.x1, ...), instead of splitting them into two separate "parallel arrays" like in the syntax above, because that way it's too easy to accidentally send the value to the wrong prop.
At the same time, such a map-based API would need to prevent the changes in the list of properties to keep things simple and avoid dealing with issues similar to #89. So, we could do something like:
And we would need N variations of that method for different arities. But at least it easily takes care of style props.
Not sure I like this exact syntax, but it does work technically, and I do want some arrows in it to indicate reactive bindings.
Lastly, I guess another approach is some kind of derivation, but I think I'd rather not have such magic in the core library, and I from my understanding, it wouldn't actually work very well in this case as the DOM props are relatively loosely typed.
The text was updated successfully, but these errors were encountered:
Sometimes people want an easier way to set multiple props from the same signal, like this:
Currently the easiest way to abstract over this is something like:
But that only helps if you need to do this a lot for the same data type / props.
We could potentially have some convenience methods for this, for example something like this:
I feel like I've seen a multi-setter like this somewhere (Laminext perhaps?) but can't find it right now.
One complication is that such an API should support mixing different kinds of keys (attrs, props, style props). Style props accept
V | String
, not justV
, unlike other types of props, so would need special handling.Ideally we would design an API that keeps a localized "map" of keys and values (e.g.
(svg.x1 -> v.x1, ...)
, instead of splitting them into two separate "parallel arrays" like in the syntax above, because that way it's too easy to accidentally send the value to the wrong prop.At the same time, such a map-based API would need to prevent the changes in the list of properties to keep things simple and avoid dealing with issues similar to #89. So, we could do something like:
And we would need N variations of that method for different arities. But at least it easily takes care of style props.
Not sure I like this exact syntax, but it does work technically, and I do want some arrows in it to indicate reactive bindings.
Lastly, I guess another approach is some kind of derivation, but I think I'd rather not have such magic in the core library, and I from my understanding, it wouldn't actually work very well in this case as the DOM props are relatively loosely typed.
The text was updated successfully, but these errors were encountered: