code-connect icon indicating copy to clipboard operation
code-connect copied to clipboard

SwiftUI generic type support

Open dlbuckley opened this issue 1 year ago • 3 comments

The component property of the FigmaConnect type doesn't easily allow for use of generic types, you have to specify every specific combination of generic constraints for that type which can quickly get out of hand.

It would be nice to be able to pass in a String just for the name of that type without having to worry about the generic constraints and then somehow mark other types which could be contained within that type. This is useful for container types views such as a generic list item which could contain a leading, trailing and content 'slot' which could contain any other view type.

dlbuckley avatar Jul 22 '24 13:07 dlbuckley

Hey @dlbuckley, thanks for the feedback. This is an area that we're actively looking into solutions for right now -- I'll discuss with the team about potential options here for how we can make this less cumbersome.

For now a solution we use internally is to use type erased types as generic parameters such as AnyView which might help to reduce the combinations of constraints that you need to sepcify.

jyyang0 avatar Jul 23 '24 15:07 jyyang0

Hey @dlbuckley, just wanted to give a quick update that the component field is going to be optional starting from v1.0.4 which should release tomorrow. We're still discussing how to handle these cases, but for now it should alleviate problems with generic since you won't need to implement this in your code connect files.

jyyang0 avatar Aug 06 '24 13:08 jyyang0

Thanks for the update @jyyang0, we will check it out!

dlbuckley avatar Aug 07 '24 10:08 dlbuckley