Replies: 6 comments 5 replies
-
Only phone but try adding a _ before the protocol field so it matches the backing field |
Beta Was this translation helpful? Give feedback.
-
It's also not clear to me where the public protocol ScenePresenterState: Equatable {
associatedtype DestinationState: RawRepresentable
var _destination: PresentationState<DestinationState>? { get set }
} or public protocol ScenePresenterState: Equatable {
associatedtype DestinationState: RawRepresentable
var _destination: PresentationState<DestinationState?> { get set }
} I tried both but neither worked. |
Beta Was this translation helpful? Give feedback.
-
@wtruppel Unfortunately i think it isn't possible to model that design as a protocol requirement. The main issues being:
|
Beta Was this translation helpful? Give feedback.
-
Have you considered implementing a protocol witness, and adding it as a dependency?Best,Nevill WilderOn Jun 13, 2023, at 01:56, Wagner ***@***.***> wrote:
Hi @pyrtsa , thank you for your response.
That's unfortunate, because I have some common behaviour that I could move to a protocol extension if I could write the protocol I wanted. As it is, I'll have quite a bit of repeated code.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Could you elaborate on what you’re trying to do? As above I don’t think you can model this as a protocol. If you’re trying to reduce some boilerplate, maybe macros will help in the near future. |
Beta Was this translation helpful? Give feedback.
-
Hey Wagner, I was noticing that you were saving destination state in your protocol. I’m curious what the intent is behind that Perhaps you’re trying to perform some mutations on the destinations state before it is created? Are you sure you want to directly edit that state outside the scope of the destination reducer? I ask these questions because there are other patterns in the TCA that should allow you to interact with child state without exposing it to other reducers.Otherwise, I would advise that you go and look at the series of pointfree episodes on protocol witnesses, and see if you can do everything you’re trying to do with your protocol using a concrete witness typeBest,Nevill WilderOn Jun 14, 2023, at 01:49, Wagner ***@***.***> wrote:
Hi @lukeredpath. Thanks for replying to my question.
As I indicated, I'm trying to create a protocol for certain reducer state types (those that participate in navigation) because those types have code (not just boilerplate) that I could move into a protocol extension so that I wouldn't have to repeat it in every type. Macros would definitely help but we can't make use of them just yet. It's not a huge deal, just more code to write and maintain at the moment.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello :)
I'm trying to create a protocol for reducer state types that participate in navigation by requiring them to have a
property but the compiler doesn't let property wrappers in protocol requirements so this isn't valid Swift code:
I thought this might work, instead,
but the compiler still complains that my states don't conform to the
ScenePresenterState
protocol. I was under the impression that property wrappers make it look like the property being wrapped is of the type we care about but, under the hood, it's actually of the wrapper type, so why doesn't the latter work? And if the latter doesn't work, can someone offer a solution?Many thanks in advance.
Beta Was this translation helpful? Give feedback.
All reactions