fluent-kit icon indicating copy to clipboard operation
fluent-kit copied to clipboard

Separate Field property wrappers into separate package

Open lmcd opened this issue 1 year ago • 1 comments
trafficstars

I have a model In my project that is simply serialised and sent to a Swift server to process. My client-side build needs a whole bunch of nio dependancies simply to accommodate some properties decorated with a @Field annotation.

Is it possible to separate this so I can use @Field, @ID etc without needing swift-nio?

lmcd avatar Mar 04 '24 18:03 lmcd

@lmcd No I don't think it is. The property wrappers require the enclosing type to be a Model to make all the syntactic sugar work and there's not really a way around that.

For sharing models across server and clients, we strongly recommend sharing only DTOs which doesn't have this issue

0xTim avatar Mar 20 '24 18:03 0xTim

There's no way to solve this with protocols? Seems a bit over the top that just defining a model needs to import a massive event loop library and all of its dependancies, and there's no possible way to disentangle the two.

lmcd avatar Mar 21 '24 15:03 lmcd

You can't require property wrappers on properties in a protocol so there's no way for us to achieve this unfortunately

0xTim avatar Mar 22 '24 01:03 0xTim

Will close this out, feel free to reopen if you have any other suggestions

0xTim avatar Mar 23 '24 01:03 0xTim